#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?m)^([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Za-z][0-9]{1,2})|(([AZa-z][0-9][A-Za-z])|([A-Za-z][A-Za-z][0-9][A-Za-z]?)))? ?[0-9][A-Za-z]{2}$"
Local $sString = "Ivy Cottage, Rockley,SN81RT" & @CRLF & _
"11 Brabourne Gardens, North Shields,NE299JB" & @CRLF & _
"2 Russell Gardens, Whitchurch,RG287AY" & @CRLF & _
"14 Red Barns, Newcastle Upon Tyne,NE12TP" & @CRLF & _
"1 Hollybank, Tamworth Road, Lichfield,WS149JE" & @CRLF & _
"69 Burnlee Road, Holmfirth,HD92PS" & @CRLF & _
"30 Cashio Lane, Letchworth Garden City,SG61AX" & @CRLF & _
"14 Cedartree Gardens, Whitley Bay,NE258XN" & @CRLF & _
"518A Victoria Road, Ruislip,HA40HD" & @CRLF & _
"9 Pear Avenue, Leeds,LS168GT" & @CRLF & _
""
Local $sSubst = "$0@"
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