using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(\(\s?function+.formula.*\{\s?)([\w|\.]+\s?=[^\}]*)(\s?\}\s?\)\s?\(\s?\)\s?;)";
string substitution = @"Calcular('$2'); ";
string input = @" (function Formula(x){ ListaOP.FormaPActiva.RemanenteACancelar = ListaOP.OPActiva.TotalesCliente.Total - ListaOP.OPActiva.MontoAcumuladoFormasPago; })(variableX);
(function Formula() { ListaOP.FormaPActiva.ImporteACancelar = ListaOP.FormaPActiva.RemanenteACancelar; })();
(function formula(){ a=b; })();
if (!v.Parametros.AfectarGastoEnvioRecargoFinanciero && ListaOP.OPActiva.MontoCanceladoContado < v.GastoEnvio + v.GastoEnvioImpuestoCliente) {
(function formula() { ListaOP.FormaPActiva.RemanenteACancelar = ListaOP.FormaPActiva.RemanenteACancelar - v.GastoEnvio - v.GastoEnvioImpuestoCliente; })();
}
var c = function(){
};
(function Formula() { ListaOP.FormaPActiva.ImporteFinanciamientoTotal = ListaOP.FormaPActiva.RemanenteACancelar * (ListaOP.FormaPActiva.CoeficienteFinanciacion - 1); })();
(function Formula() { ListaOP.FormaPActiva.ImporteACancelar = ListaOP.FormaPActiva.ImporteACancelar + ListaOP.FormaPActiva.ImporteFinanciamientoTotal; })();
(function Formula(x) { ListaOP.FormaPActiva.RemanenteACancelar = ListaOP.FormaPActiva.ImporteACancelar; })(10);";
RegexOptions options = RegexOptions.IgnoreCase;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx