#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?'start'\{\n)|((?'line' (?U)(".*")\: (".*")(?-U),?\n))|(?'end'\})"
Local $sString = "{" & @CRLF & _
" "word1": "category1"," & @CRLF & _
" "word2": "category2"," & @CRLF & _
" "word3": "category3"," & @CRLF & _
" "word4": "category4"," & @CRLF & _
" "word5": "category5"," & @CRLF & _
" "word6": "category6"," & @CRLF & _
" "word7": "category7"" & @CRLF & _
"}"
Local $sSubst = "${start:+CASE\n}${line:+ WHEN $4 THEN $5\n}${end:+ ELSE "other"\nEND}"
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