#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?xm)^((?! # This and the final line allow invert the regex condition" & @CRLF & _
"" & @CRLF & _
"PA(?:" & @CRLF & _
" \*(?:N\s*\d+\s*\.\s*\d+\s*\*ADP)? # match the asterisk cases" & @CRLF & _
" | \#\s*N\s*\d+\s* # or the hash cases" & @CRLF & _
" (?:[\.,-]\s*\d+\s*){0,5}" & @CRLF & _
" \#ADP\s*(?:\d|\#PUSH)" & @CRLF & _
" | \#NUAL,AZ,AN\#FOP\d # or the 'UAL,AZ,AN' literal" & @CRLF & _
")" & @CRLF & _
"" & @CRLF & _
").)*$"
Local $sString = "# OP's samples" & @CRLF & _
"PA#N1.1#ADP1" & @CRLF & _
"PA#N1.1,1.2#ADP1,2" & @CRLF & _
"PA#N1#ADP4" & @CRLF & _
"PA#N1,2#ADP4" & @CRLF & _
"PA#N1,2.1,3#ADP1" & @CRLF & _
"PA#N1.1-3#ADP1" & @CRLF & _
"PA#N1.1- 3.2#ADP1,2" & @CRLF & _
"PA#NUAL,AZ,AN#FOP123" & @CRLF & _
"PA#N1.1-2.1,3.1#ADP#PUSH" & @CRLF & _
"PA*N1.1*ADP" & @CRLF & _
"PA*" & @CRLF & _
"" & @CRLF & _
"# The same with some spaces adde here and there" & @CRLF & _
"PA# N 1.1 #ADP1" & @CRLF & _
"PA#N 1.1,1.2#ADP1,2 " & @CRLF & _
"PA#N1#ADP4 " & @CRLF & _
"PA#N1,2 #ADP4 " & @CRLF & _
"PA#N1,2. 1,3#ADP1 " & @CRLF & _
"PA#N1.1-3#ADP1" & @CRLF & _
"PA#N1.1- 3.2#ADP1,2 " & @CRLF & _
"PA#NUAL,AZ,AN#FOP123 " & @CRLF & _
"PA#N1.1-2 . 1 , 3 . 1 #ADP#PUSH " & @CRLF & _
"PA*N1 .1*ADP " & @CRLF & _
"" & @CRLF & _
"PA#N1.1...#5#SOME TEXT" & @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