#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mx)^(?:(?<track>\d{1,3}) \s*[\s-]\s*)?" & @CRLF & _
"(?:(?<artist>.+?) \s*-\s*)?" & @CRLF & _
"(?<title>.+)" & @CRLF & _
"(?<ext> \.mp3)"
Local $sString = "01 Example Artist - Example Song.mp3" & @CRLF & _
"" & @CRLF & _
"01 Example Song.mp3 (In this example, there's no artist so that group should be null)" & @CRLF & _
"" & @CRLF & _
"Example Artist - Example Song.mp3" & @CRLF & _
"" & @CRLF & _
"Example Song.mp3 (Again, no artist)"
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