Re: requiring balanced parens in a regexp?

"Peter Michaux" <petermichaux@gmail.com>
10 Nov 2006 02:14:49 -0500

          From comp.compilers

Related articles
requiring balanced parens in a regexp? petermichaux@gmail.com (Peter Michaux) (2006-11-10)
Re: requiring balanced parens in a regexp? petermichaux@gmail.com (Peter Michaux) (2006-11-10)
Re: requiring balanced parens in a regexp? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-11-10)
Re: requiring balanced parens in a regexp? martin@gkc.org.uk (Martin Ward) (2006-11-10)
Re: requiring balanced parens in a regexp? haberg@math.su.se (2006-11-10)
Re: requiring balanced parens in a regexp? alexc@TheWorld.com (Alex Colvin) (2006-11-10)
Re: requiring balanced parens in a regexp? cfc@shell01.TheWorld.com (Chris F Clark) (2006-11-10)
| List of all articles for this month |
From: "Peter Michaux" <petermichaux@gmail.com>
Newsgroups: comp.compilers
Date: 10 Nov 2006 02:14:49 -0500
Organization: Compilers Central
References: 06-11-039
Keywords: parse
Posted-Date: 10 Nov 2006 02:14:49 EST

Hi John,


Peter Michaux wrote:
> > Can JavaScript regular expressions ensure that all
> > parentheses to the right of "test" are closed before proclaiming a
> > match? If so how? If not must I walk through the string counting how
> > nested each character is?
>
> [Matching parentheses is the classic problem that pure regexp's cannot
> solve, because they have no way to count the number of unmatched
> parens. There's a variety of ways to fake it, e.g., take your string,
> replace each ([^)]+) by a space until there aren't any left, then look
> for your match. Or use various extended regexps that are more like
> parsers. -John]


Thanks for the info. My problem is even bigger as there might be mixed
quotes with various balance in relation to the parens.


I think that I will need to write a real tokenizer and parser to get my
job done properly. I haven't done that before and it is something I
have always wanted to do but it seems like a *big* task.


Thanks again,
Peter


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.