Menu
comp.lang
Embarcadero
Microsoft
Related Sites

Newsgroup: embarcadero.public.cppbuilder.webservices


Arnshea - regexes with balancing group definitions -   05 Oct, 15:49 [ Get full thread ]  
regexes with balancing group definitions
There's an article (well, an editor's update to an article - at
http://msdn.microsoft.com/msdnmag/issues/04/06/NETMatters/#edupdate )
that presents the following regular expression for detecting balanced
brackets.

string pattern =
    @"^((?<openBracket>\{) | [^\{\}] |" +
    @"(?<closeBracket-openBracket>\}))*" +
    @"(?(openBracket)(?!))$";

What is the purpose of the last line?  Shouldn't

^((?<openBracket>\{) | [^\{\}] | (?<closeBracket-openBracket>\}))*$

be sufficient?

Jesse Houwing - Re: regexes with balancing group definitions -   06 Oct, 20:29 [ Get full thread ]  

Click on title to retrieve message.