explainable RegEx behavior?

  • Thread starter Thread starter Relishguy
  • Start date Start date
R

Relishguy

OK, so I am was never so good on NFAs and DFAs, but I am just trying
to get one of the Microsoft-supplied RegEx samples to work. It is the
last example (describing the Capture class) from this page:

http://msdn.microsoft.com/library/d...e/html/cpconusingregularexpressionclasses.asp

Basically, it returns no Groups as coded. If I change the RegEx to
"(abc)+", it works like I would expect (since this says one or more
groups rather than zero or more groups).

I would think that "zero or more" of this construct would also work.

I got my (real oproject) code to work, but I am probably going to run
into some problem in the future, that will have the same answer as
this weird case, so..

Thanks in advance.

Regards..
 
Did I get you right? You want to match something like "(abc)*"?
This should match just about anything, as any character location can be read
as "0 repetitions of (abc)"
You should have some must-be-there-string in front of or after a 0-or-more
expression, like "(abc)*def"

There's an excellent book on the topic "Mastering regular expressions".
Really worth the price!

Niki
 
Back
Top