#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?mx)(?<First>\w+?) (?# First word UNGREEDY)" & @CRLF & _
"(?> (?# Second group - see it is optional)" & @CRLF & _
" (?>_) (?# But if it exists, must start with "_" NON CAPTURING GROUP )" & @CRLF & _
" (?<Second>\w+) (?# Snd then there should be a word - at least one char)" & @CRLF & _
")* (?# remember - the group is optional)" & @CRLF & _
"\b (?# All the puttern must finish with word boundary)"
Local $sString = " BRIGHTER " & @CRLF & _
" DIMMER " & @CRLF & _
"" & @CRLF & _
" CYCLE_RGB " & @CRLF & _
" CYCLE_ALL " & @CRLF & _
"" & @CRLF & _
" PULSE_WHITE " & @CRLF & _
" SMOOTH " & @CRLF & _
""
Local $sSubst = "\U${FirstUpper}\L${FollowingUppers}\U${SecondUpper}\L${FollowingUppers2} = ${HexCode},"
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