#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?ms)(location \/api.*?proxy_pass\s*)([^ ;]+)"
Local $sString = "server {" & @CRLF & _
" listen 80;" & @CRLF & _
" server_name localhost;" & @CRLF & _
"" & @CRLF & _
" location /api {" & @CRLF & _
" rewrite /api/(.*) /$1 break;" & @CRLF & _
" proxy_pass https://host.name:1337;" & @CRLF & _
" proxy_redirect off;" & @CRLF & _
" proxy_set_header Host $host;" & @CRLF & _
" }" & @CRLF & _
" location / {" & @CRLF & _
" root /usr/share/nginx/html;" & @CRLF & _
" index index.html index.htm;" & @CRLF & _
" }" & @CRLF & _
"}"
Local $sSubst = "$1http://localhost:1234"
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