Practical Parsing Using Groups in Regular Expressions

My blog has moved.
You can view this post at the following address:
http://www.osherove.com/blog/2003/5/12/practical-parsing-using-groups-in-regular-expressions.html
Published Monday, May 12, 2003 11:40 PM by RoyOsherove
Filed under:

Comments

Wednesday, May 28, 2003 6:34 PM by Shawn A. Van Ness

# How to enumerate the named capturing groups in a regex?

Hi Roy,

First off, if you were using the regex-based C# colorizer that Wes H and I have been working on, that anglebracket bug was my fault. Sorry! ;)

But that's not why I'm writing... or actually yes, it is. I was trying to add a feature to that same product, one which would ultimately require "reflecting" on a user-entered regex to get a list of named capturing groups.

Short of scanning a regex pattern with a regex (ugh!) I can't seem to find a way to do that.

IOW, it looks like although GroupCollection allows us to index by string, it doesn not allow us to enumerate by string.

You may have more experience than me, in this area -- am I missing something?

Wednesday, May 28, 2003 6:59 PM by Royo

# re: Practical Parsing Using Groups in Regular Expressions

Hey Shawn.
Actually, I Copy-Pasting from VS.NET into the editor.
Second, As for your question, It seems a pretty complicated case, and off the top of my head, I can't think of a better way than parsing Regex patterns with Regex patterns :)

However, If i'll come up with something , I'll let you know about it :)
I suggest, If you havn't yet, Trying to post on the Regex Mailing list from ASPAlliance.com
The folks there might help...
They have more experience than me on this subject.
Tuesday, June 15, 2004 7:36 PM by codevigilante

# re: Practical Parsing Using Groups in Regular Expressions

A quick question, how would one format the regular expression if the months were stored as Jan, Feb, Mar, etc. ? I have been trying to learn regular expressions and cannot figure it out.
Saturday, July 10, 2004 10:42 AM by Robert

# re: Practical Parsing Using Groups in Regular Expressions

Hello!
You use th format dd/MM/yyyy for date.
why don't use yyyy-MM-dd ?
i've seen many and many examples that use dd/MM/yyyy format.
But i think that format make confusion.
It's my personal opinion and problem?
Friday, July 14, 2006 1:22 PM by AL

# re: Practical Parsing Using Groups in Regular Expressions

I was wondering how to use regular expressions to parse columns of a line?