#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(754|1231)|[^A-Za-z\s]"
Local $sString = "Dividends 9672" & @CRLF & _
"Dividends 9680" & @CRLF & _
"Interest Income" & @CRLF & _
"Ordinary Dividends" & @CRLF & _
"Royalties" & @CRLF & _
"Capital Gain Distributions" & @CRLF & _
"Income from Blackstone" & @CRLF & _
"Ordinary Income" & @CRLF & _
"Rental Income" & @CRLF & _
"Long Term Capital Gain" & @CRLF & _
"Short Term Capital Gain" & @CRLF & _
"1231 Gain" & @CRLF & _
"Section 754 Stock Basis Adjustment - 2015" & @CRLF & _
"M-1 Section 754 Stock Basis Adjustment - 2015" & @CRLF & _
"Section 754 Stock Basis Adjustment - 2018" & @CRLF & _
"M-1 Section 754 Stock basis adjustment - 2018"
Local $sSubst = "\1"
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