#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?i)(\(\s?function+.formula.*\{\s?)([\w|\.]+\s?=[^\}]*)(\s?\}\s?\)\s?\(\s?\)\s?;)"
Local $sString = " (function Formula(x){ ListaOP.FormaPActiva.RemanenteACancelar = ListaOP.OPActiva.TotalesCliente.Total - ListaOP.OPActiva.MontoAcumuladoFormasPago; })(variableX);" & @CRLF & _
" (function Formula() { ListaOP.FormaPActiva.ImporteACancelar = ListaOP.FormaPActiva.RemanenteACancelar; })();" & @CRLF & _
"(function formula(){ a=b; })();" & @CRLF & _
" if (!v.Parametros.AfectarGastoEnvioRecargoFinanciero && ListaOP.OPActiva.MontoCanceladoContado < v.GastoEnvio + v.GastoEnvioImpuestoCliente) {" & @CRLF & _
" (function formula() { ListaOP.FormaPActiva.RemanenteACancelar = ListaOP.FormaPActiva.RemanenteACancelar - v.GastoEnvio - v.GastoEnvioImpuestoCliente; })();" & @CRLF & _
" }" & @CRLF & _
"var c = function(){" & @CRLF & _
"" & @CRLF & _
"};" & @CRLF & _
" (function Formula() { ListaOP.FormaPActiva.ImporteFinanciamientoTotal = ListaOP.FormaPActiva.RemanenteACancelar * (ListaOP.FormaPActiva.CoeficienteFinanciacion - 1); })();" & @CRLF & _
"" & @CRLF & _
" (function Formula() { ListaOP.FormaPActiva.ImporteACancelar = ListaOP.FormaPActiva.ImporteACancelar + ListaOP.FormaPActiva.ImporteFinanciamientoTotal; })();" & @CRLF & _
" (function Formula(x) { ListaOP.FormaPActiva.RemanenteACancelar = ListaOP.FormaPActiva.ImporteACancelar; })(10);"
Local $sSubst = "Calcular('$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