By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,464 Members | 1,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,464 IT Pros & Developers. It's quick & easy.

regex groups

P: n/a
How does one figure out match.groups for a regex string? Here is the
expression,
"([12]\d{3}-[A-Z]\d{3})(\d{3})?((-)(\d{4})(\d{2}))?((-)(0\d{2})(\d{2}))?((-)(0\d{2})(\d{2}))?((-)(0\d{2})(\d{2}))?"
and here is an example string 1013-A109400-480001-00701-05601-06501 .
I've tried searching msdn and the net and nothing seems to make sense
to me.

Thanks

Dwight

Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try Expresso:

http://www.codeproject.com/dotnet/expresso.asp

--------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #2

P: n/a
dw****@trumbower.com wrote:
How does one figure out match.groups for a regex string? Here is the
expression,
"([12]\d{3}-[A-Z]\d{3})(\d{3})?((-)(\d{4})(\d{2}))?((-)(0\d{2})(\d{2}))?((-)(0\d{2})(\d{2}))?((-)(0\d{2})(\d{2}))?"
and here is an example string 1013-A109400-480001-00701-05601-06501 .


Give the groups a name by prefixing with "?<name>, e.g. (untested)

Match m = Regex.Match(s, @"(?<s1>\d+)(?<s2>\d+)");
System.Console.WriteLine("s1: " + s1 + ", s2: " + m.Groups["s2"]);

HTH & kind regards
frank
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.