#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?mi)^a\..*?\Kain't"
Local $sString = "For instance, if in the text below I wanted to replace "ain't" with "is not" for lines beginning "a." but not "b.":" & @CRLF & _
"a. This ain't a worm." & @CRLF & _
"b. No, it ain't." & @CRLF & _
"a. Ain't a snake, either." & @CRLF & _
"b. No, ain't one of them. " & @CRLF & _
"a. ain't multiple ain't and more ain't" & @CRLF & _
""
Local $sSubst = "is not"
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