And here comes yet another approach:
static void Main(string[] args) {
string text = "<script type=\"text/javascript\">var d=[];d=[['123','Product A','$230'],['125','Product B','$30'],['126','Product C','$50']];show(d);</script>";
string pattern = "(?<=\\[)\\'.+?(?=\\])";
List<string> lst = new List<string>();
foreach (Match item in Regex.Matches(text,pattern)) {
lst.Add(item.Value);
}
foreach (var item in lst) {
string[] arr = item.Split(',');
foreach (var value in arr) {
Console.Write("{0}{1}", value, "\t");
}
Console.WriteLine();
}
Console.ReadKey();
}
wizend
No comments:
Post a Comment