#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)([a-zA-Z_]\w+|[a-zA-Z]\w*|\[\s*[a-zA-Z_]\w+\s*\]|\[\s*[a-zA-Z]\w*\s*\])\s*\[\s*['"]([a-zA-Z_]\w+|[a-zA-Z]\w*)['"]\s*\]"
Local $sString = "a['b'][c]" & @CRLF & _
"a['1']" & @CRLF & _
"a['b1']" & @CRLF & _
"a[1]" & @CRLF & _
"a['_'] --I am pretty sure this is bad to match" & @CRLF & _
"a["__"] --idk if this is bad to match" & @CRLF & _
"a["_ _"] " & @CRLF & _
"a["up"]" & @CRLF & _
"a["up "]" & @CRLF & _
"a['b']['c'] --notice how this doesn't match the first quote with the last one" & @CRLF & _
"a["workwork"]" & @CRLF & _
"_adf [ 'test' ] --even when imporoperlly formated this is valid lua" & @CRLF & _
"a.[b] ["yup"] --this case preserves the [b] and will append .yup after it" & @CRLF & _
"a["a.basdf"]" & @CRLF & _
""adlfkajsd.dklajdlakj""
Local $sSubst = "$1.$2"
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