#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)_(?!(?<=(?<!\d)\d{8}_)\d{6}(?!\d))"
Local $sString = "Patate_17890505_TitreEnCamelCase.ext" & @CRLF & _
"EPFL_AlgebreLineaire" & @CRLF & _
"TaxonomieProprietesFonctionsComplexes.v0.ipe.20210302_005606.pdf" & @CRLF & _
"1_" & @CRLF & _
"12_" & @CRLF & _
"_1" & @CRLF & _
"_12" & @CRLF & _
"12345678_" & @CRLF & _
"_123456" & @CRLF & _
"12345678_12345" & @CRLF & _
"1234567_123456" & @CRLF & _
"1234567_12345" & @CRLF & _
"123456_12345" & @CRLF & _
"12345678_1234567" & @CRLF & _
"123456789_123456" & @CRLF & _
"123456789_1234567" & @CRLF & _
"_patate__truc__" & @CRLF & _
"___" & @CRLF & _
"foo_12345678" & @CRLF & _
"foo_12345678_123456_bar" & @CRLF & _
"12345678_123456" & @CRLF & _
"foo12345678_123456bar"
Local $sSubst = "."
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm