#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?:(4\d{3}(?P<DelimVI>[\ \-]?)(?:\d{4}(?P=DelimVI)){2}\d(?:\d{3})?)|(5([1-5]\d{2})(?P<DelimMC>[\ \-]?)\d{4}(?P=DelimMC)\d{4}(?P=DelimMC)\d{4})|(3[47]\d\d(?P<DelimAX>[\ \-]?)\d{6}(?P=DelimAX)\d{5}))"
Local $sString = ""This is Visa number 4111111111111111, next is MasterCard number 5105105105105100, next is Amex 378282246310005"" & @CRLF & _
"" & @CRLF & _
"//Visa 13 or 16 digits with optional delimiters of spaces or dashes between number groups, e.g.“4012-8888-8888-1881” or “4012-8888-8888-1”." & @CRLF & _
""//Master 16 digits with optional delimiters of spaces or dashes between number groups, e.g.“5112-8888-8888-1881” " & @CRLF & _
" //American Express with optional matching delimiters of spaces or dashes between number groups, e.g. “3714-496353-98431” or “3714 496353 98431”, but not mix of delimeters “3714-496353 98431” ." & @CRLF & _
"" & @CRLF & _
"(4\d{3}(?P<DELIM>[\ \-]?)(?:\d{4}(?P=DELIM)){2}\d(?:\d{3})?)" & @CRLF & _
"" & @CRLF & _
"(?:(4\d{3}(?P<DelimVI>[\ \-]?)(?:\d{4}(?P=DelimVI)){2}\d(?:\d{3})?)|(5([1-5]\d{2})(?P<DelimMC>[\ \-]?)\d{4}(?P=DelimMC)\d{4}(?P=DelimMC)\d{4})|(3[47]\d\d(?P<DelimAX>[\ \-]?)\d{6}(?P=DelimAX)\d{5}))"
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