#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(\b(?'first_word'[a-z](?!([[:alnum:]]*_)(?# the word doesn't contain underscores))(?:[a-z0-9]*)))|(\G(?'trailing_word'[A-Z][a-z0-9]*))"
Local $sString = "camelCase" & @CRLF & _
"camel" & @CRLF & _
"camelCaseCase" & @CRLF & _
"camel684Case" & @CRLF & _
"ca45melCase" & @CRLF & _
"camelCase6523Case" & @CRLF & _
"camelCaseCaseCaseCaseCase" & @CRLF & _
"camelCCase" & @CRLF & _
"PascalCase" & @CRLF & _
"// some random commentary with Capitalized letters" & @CRLF & _
"camel_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