#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?ms)^(\s*)case\s+([^:]*?)\s*:(.*?)\s*break;?"
Local $sString = "switch (new Date().getDay()) {" & @CRLF & _
" case 0:" & @CRLF & _
" day = "Sunday";" & @CRLF & _
" break;" & @CRLF & _
" case 1:" & @CRLF & _
" day = "Monday";" & @CRLF & _
" break;" & @CRLF & _
" case 2:" & @CRLF & _
" day = "Tuesday";" & @CRLF & _
" break;" & @CRLF & _
" case 3:" & @CRLF & _
" day = "Wednesday";" & @CRLF & _
" break;" & @CRLF & _
" case 4:" & @CRLF & _
" day = "Thursday";" & @CRLF & _
" break;" & @CRLF & _
" case 5:" & @CRLF & _
" day = "Friday";" & @CRLF & _
" break;" & @CRLF & _
" case 6:" & @CRLF & _
" day = "Saturday";" & @CRLF & _
" break;" & @CRLF & _
"}"
Local $sSubst = "$1$2 -> {$3\n$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