Geeks With Blogs
Michael Holland
REGEX is not exactly my favorite technology to have to work with, but there are times when it is definitely the right tool for the job. Recently I needed to parse a large text file that contained blocks of information within curly brackets - {}.

I found a great solution for the REGEX at:

Note that balancing groups is only in the Microsoft REGEX classes... if you are using a different library you may have to follow an alternative, less powerful route where you know the number of levels that may be used:

KUDOS to Steve...

My final solution by the way was:
@"\{(?>[^{}]+|\{(?)|\}(?<-Depth>))*(?(Depth)(?!))\}" Posted on Saturday, January 17, 2009 5:05 PM | Back to top

Comments on this post: Using REGEX to find text within brackets or parenthesis

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © LEV | Powered by: