#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?im)([a-zA-Z][a-zA-Z0-9]{1,3}) ?(\d[a-zA-Z]{2})"
Local $sString = "EC1A 1BB" & @CRLF & _
"A9A 9AA" & @CRLF & _
"A9 9AA" & @CRLF & _
"A99 9AA" & @CRLF & _
"AA9 9AA" & @CRLF & _
"AA99 9AA" & @CRLF & _
"EC1A1BB" & @CRLF & _
"A9A9AA" & @CRLF & _
"A99AA" & @CRLF & _
"A999AA" & @CRLF & _
"AA99AA" & @CRLF & _
"AA999AA"
Local $sSubst = "$1 $2"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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