#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?i)(?m)(?<=^ *) {4}"
Local $sString = "{" & @CRLF & _
" "Foo": "bar"," & @CRLF & _
" "Kestrel": {" & @CRLF & _
" "Endpoints": {" & @CRLF & _
" "Http": {" & @CRLF & _
" "Url": "http://*:2201"" & @CRLF & _
" }," & @CRLF & _
" "HttpsInlineCertStore": {" & @CRLF & _
" "Url": "https://*:2203"," & @CRLF & _
" "SslProtocols": [" & @CRLF & _
" "Tls12"," & @CRLF & _
" "Tls13"" & @CRLF & _
" ]," & @CRLF & _
" "Certificate": {" & @CRLF & _
" "Subject": "SubjectName"," & @CRLF & _
" "Store": "My"," & @CRLF & _
" "Location": "CurrentUser"," & @CRLF & _
" "AllowInvalid": "True"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}"
Local $sSubst = " "
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