using System.Text.RegularExpressions;
private static string EvalExpr(string sExpression)
Random random = new Random();
sExpression = Regex.Replace(
new MatchEvaluator(delegate(Match m)
int randomNumber = random.Next(100);
string sRes = randomNumber<50 ? "0" : "1";
Console.WriteLine("Simulated response of {0}: {1}", m.Groups[0].Value, sRes);
public static void Main()
string sExpr = "((Loan number is 1000 And Lock Date is less than 12/03/2015) Or Borrower SSN contains 12345) And ((Buy date is between 12/01/2015 and 23/02/2016 And APR is less than 20000) Or Loan amount is greater than 60000)";
Console.WriteLine(EvalExpr(sExpr));