Balanced matching using .NET Regex

By Roy Osherove In Regex

Markdown version

Historical article · Originally published June 19, 2005; technical details may be outdated.

.NET Regular expressions have an extended ability to match "balanced items". For example, in the string
"a + (b+(c+d))" it can find correct pairs of matching open and closing brackets.
It's not the most simple solution in the world, so be ready for a small mind-melt when you read this from the BCL team (Base class library team at MS)

More in Regex

All posts in Regex