
1 May
2007
1 May
'07
2:16 p.m.
Lorenzo wrote:
is there a way to specify open and closed parenthesis with a regular expression syntax? For instance, if I'd want to specify a single regular expression that matches both (foo) and [foo] and {foo}?
Lorenzo, Matching parentheses to arbitrary depth is, like matching palindromes, a textbook example of something that cannot be done with a regular language and instead needs a context-free language. Google for "chomsky hierarchy palindrome" for some background material. Of course, it's possible that some regexp library somewhere has a hack to add this functionality. But fundamentally, you need a more sophisticated parser. Phil.