Saturday, May 11, 2013

How to validate data using regex?

This may help:



string pattern = "(?<=\\[)('\\d+'),(\\d{0,1}),('\\w+\\s?\\w+'),('\\$\\d+')(?=\\])";

foreach (Match item in Regex.Matches(text,pattern)) {
Console.WriteLine("{0}{1,5}{2,5}{3,10}", item.Groups[1], item.Groups[2], item.Groups[3], item.Groups[4]);
}



wizend

No comments:

Post a Comment