#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?<!SQ\d{0}|\d|\d{2})(51\d{14}|52\d{14}|53\d{14}|54\d{14}|55\d{14}|36\d{12}|34\d{13}|37\d{13}|4\d{15}|4\d{12}|\d{4}(-|\s)\d{4}(-|\s)\d{4}(-|\s)\d{4}|\d{3}(-|\s)\d{3}(-|\s)\d{3}(-|\s)\d{3}(-|\s)\d{3}|\d{4}(-|\s)\d{6}(-\s)\d{5}|6\d{15})"
Local $sString = "<Payment>" & @CRLF & _
" <PCard expiration="2061-04-00" name="Grainger AB" number="41111111111111114222222222222"/>" & @CRLF & _
"</Payment>" & @CRLF & _
"<PCard expiration="2022-04" number="4005-5511-2233-4450"/>" & @CRLF & _
"<Payment>" & @CRLF & _
"Space" & @CRLF & _
"<PCard expiration="2022-04" number="4005 5511 2233 4450"/>" & @CRLF & _
"Tab space" & @CRLF & _
"<PCard expiration="2022-04" number="4005 551122334450"/>" & @CRLF & _
"<PCard expiration="2022-04" number="4005 5511 2233 4450"/>" & @CRLF & _
"new line" & @CRLF & _
"<PCard expiration="2022-04" number="4005400540054005"/>" & @CRLF & _
"<PCard expiration="2022-04" number="4005 5511 2233 4450"/>" & @CRLF & _
"carriage return" & @CRLF & _
"<PCard expiration="2022-04" number="4005 5511 2233 4450"/>" & @CRLF & _
"</Payment>" & @CRLF & _
"combination of" & @CRLF & _
"<Payment>" & @CRLF & _
" <PCard expiration="2022-04" number="4005- 5511 -2233-4450"/>" & @CRLF & _
"</Payment>" & @CRLF & _
"" & @CRLF & _
"<PCard expiration="2061-04-00" name="Grainger AB" number="4255726800010"/>" & @CRLF & _
"<PCard expiration="2061-04-00" name="Grainger AB" number="@#@@@$@4255726800010"/>" & @CRLF & _
"<PCard expiration="2061-04-00" name="Grainger AB" number="SQ#4255726800010"/>" & @CRLF & _
"<PCard expiration="2061-04-00" name="Grainger AB" number="45a$4255726800010"/>" & @CRLF & _
"<PCard expiration="2061-04-00" name="Grainger AB" number="12SQ%4255726800010"/>" & @CRLF & _
"" & @CRLF & _
"<PCard expiration="2061-04-00" name="Grainger AB" number="4255726800010@121212"/>" & @CRLF & _
"<PCard expiration="2061-04-00" name="Grainger AB" number="4255726800010#SQ"/>" & @CRLF & _
"<PCard expiration="2061-04-00" name="Grainger AB" number="4255726800010$a54"/>" & @CRLF & _
"<PCard expiration="2061-04-00" name="Grainger AB" number="4255726800010%SQ12"/>" & @CRLF & _
"" & @CRLF & _
"<SupplierPartID>4222222222222</SupplierPartID>" & @CRLF & _
"<SupplierPartID> 4222222222222</SupplierPartID>" & @CRLF & _
"<SupplierPartID>SQ4222222222222</SupplierPartID> " & @CRLF & _
"<SupplierPartID>SQ134222222222222</SupplierPartID> " & @CRLF & _
"<SupplierPartAuxiliaryID>WWGSQ134256726800010</SupplierPartAuxiliaryID>" & @CRLF & _
""
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