#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m).+(?=((\\|\/).+){4})"
Local $sString = "C:\Change\the\number\2\to\anything\else\and\test\and\see\what\happens" & @CRLF & _
"C:\Users\Andrew\Desktop\Folder1\Folder2\Folder3\Folder4\file.txt" & @CRLF & _
"C:\ProgramData\Microsoft\Diagnosis\EventTranscript\EventTranscript.db" & @CRLF & _
"C:\Windows\System32\config\SAM" & @CRLF & _
"C:\Windows\System32\winevt\logs\Application.evtx" & @CRLF & _
"C:\Users\%user%\AppData\Local\Microsoft\Windows\Notifications\wpndatabase.db"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
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