[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gnulib] [bug-gnulib] Does regex.c support non-greedy quantifier
From: |
Hrvoje Niksic |
Subject: |
Re: [bug-gnulib] [bug-gnulib] Does regex.c support non-greedy quantifiers? |
Date: |
Mon, 11 Apr 2005 21:09:33 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) |
Bruno Haible <address@hidden> writes:
> Hrvoje Niksic wrote:
>> Does gnulib's regex.c support Perl-style non-greedy quantifiers,
>> specified by appending "?" to "*"?
>
> Is it possible to transform a regex pattern that uses this feature
> into a POSIX Extended Regex, that doesn't use it?
I'm not sure that such a transformation is possible. With some
engines it apparently works to translate X*? to (|X)*, but that
shouldn't work with a POSIX-compliant regexp engine that correctly
implements the leftmost-longest requirement. Besides, such a
transformation adds an undesirable group to the regexp. (That could
be solved by using a shy group, but that's another Perl/Emacs feature
that POSIX regexps don't have.)
Emacs's regex.c already supports both the non-greedy quantifiers
(RE_FRUGAL) and shy groups (RE_SHY_GROUPS), both being supported by
default. If gnulib already uses GNU regex, it seems like a good idea
to use that one.
> If yes, you could parse the regex - this is not the most difficult
> thing to do, and you can also take the code from grep's dfa.c - and
> pass the transformed pattern to the system's regex facility.
In the general case, correctly parsing a regexp is not all that easy.
It would be much simpler to just use regex.c from Emacs.
Re: [bug-gnulib] [bug-gnulib] Does regex.c support non-greedy quantifiers?, Bruno Haible, 2005/04/11
- Re: [bug-gnulib] [bug-gnulib] Does regex.c support non-greedy quantifiers?,
Hrvoje Niksic <=