#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(\b(?'first_word'[A-Z](?!([A-Z0-9]*\b|[[:alnum:]]*_)(?# the word isn't in all caps and doesn't contain underscores))(?:[a-z0-9]*)))|(\G(?'trailing_word'[A-Z][a-z0-9]*))"
Local $sString = "PascalCase" & @CRLF & _
"Pascal " & @CRLF & _
"PascalCaseCase" & @CRLF & _
"Pascal684Case" & @CRLF & _
"Pas45calCase" & @CRLF & _
"PascalCase6523Case" & @CRLF & _
"PascalCaseCaseCase" & @CRLF & _
"PPascal" & @CRLF & _
"PascalCCase" & @CRLF & _
"camelCase" & @CRLF & _
"// some random commentary with Capitalized and SCREAMING letters" & @CRLF & _
"SCREAMING_SNAKE_CASE" & @CRLF & _
"Pascal_Snake_Case" & @CRLF & _
""
Local $sSubst = "\L${first_word}${trailing_word:+_\L${trailing_word}:}"
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