public static CompileExtract Extract(string url) { if (string.IsNullOrEmpty(url)) { return(null); } var regex = new Regex(@"\{#(.*?)#\}"); var ms = regex.Matches(url); if (ms.Count == 0) { return(null); } var result = new CompileExtract(); // now("yyyyMMdd") // ticks() foreach (Match m in ms) { var d = m.Value.Trim(); var f = Regex.Match(d, @"^[^\(]*").Value.Trim(); var arg = Regex.Match(f, @".?\((.*)\)+"); result.Function = f; if (arg.Success) { result.Args = JsonConvert.DeserializeObject <object[]>("[" + arg.Value + "]"); } } return(result); }
public List <CompileExtract> Extract(string url) { var results = new List <CompileExtract>(); if (string.IsNullOrEmpty(url)) { return(results); } var regex = new Regex(@"\{#(.*?)#\}"); var ms = regex.Matches(url); if (ms.Count == 0) { return(results); } foreach (Match m in ms) { var d = m.Value.Trim(); var mt = Regex.Match(d, @"{#(.*?)\("); if (!mt.Success || mt.Groups.Count != 2) { continue; } var fun = mt.Groups[1].Value.Trim(); var arg = Regex.Match(d, @"\((.*)\)+"); var result = new CompileExtract(); result.Function = fun; result.Index = m.Index; if (arg.Success && arg.Groups.Count == 2) { result.Args = JsonConvert.DeserializeObject <object[]>("[" + arg.Groups[1].Value + "]"); } results.Add(result); } return(results); }