Can regular expressions be used to match nested patterns?
Posted
by Richard Dorman
on Stack Overflow
See other posts from Stack Overflow
or by Richard Dorman
Published on 2008-09-25T14:17:40Z
Indexed on
2010/04/01
20:43 UTC
Read the original article
Hit count: 331
Is it possible to write a regular expression that matches a nested pattern that occurs an unknown number of times. For example, can a regular expression match an opening and closing brace when there are an unknown number of open closing braces nested within the outer braces.
For example:
public MyMethod()
{
if (test)
{
// More { }
}
// More { }
} // End
Should match:
{
if (test)
{
// More { }
}
// More { }
}
© Stack Overflow or respective owner