#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?mxu)\b" & @CRLF & _
"(" & @CRLF & _
" (?<abrev>(?:[A-Z]\.)+)" & @CRLF & _
" |(?<roman>M{0,4}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3}))" & @CRLF & _
" |(?<prep>(?i)d?[aoe]s?(?-i))" & @CRLF & _
" |(?<first>\w)(?<rest>\w+)" & @CRLF & _
")" & @CRLF & _
"\b"
Local $sString = "alto dO cruzeiro" & @CRLF & _
"joão paulo II" & @CRLF & _
"N.S. aparecida" & @CRLF & _
"N.S. DAS GRAÇAS"
Local $sSubst = "${abrev}${roman}\L${prep}\E\U${first}\L${rest}"
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