C# Regex groups
public void TestRegex(){//sample version regex
string regexExpression = @"^(?<Major>\d+)\.(?<Minor>\d+)\.(?<Build>\d+)\.(?<Revision>\d+)$";string text = "1.0.0.0";Regex regex = new Regex(regexExpression);
//case insensitive
//Regex regex = new Regex(regextTextBox.Text, RegexOptions.IgnoreCase);
Match match = regex.Match(text);if (match.Success)
{foreach (string groupName in regex.GetGroupNames()){Console.WriteLine("{0}={1}", groupName, match.Groups[groupName]);
}}}
Comments
Post a Comment