[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regular expressions that match nothing
From: |
Stefan Monnier |
Subject: |
Re: regular expressions that match nothing |
Date: |
Tue, 14 May 2019 15:41:31 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> Thank you, and sorry about my bad initial attempt. I tried a few more,
> like [z-a], \c* and \sq, but these were no better. The distribution is
> decidedly bimodal; there seems to be no significant difference between
> the 'fast' ones,
Not surprised: the "fast" ones are the ones that the regexp engine
recognizes as "anchored" so the search is reduced to a looking-at.
> so I went with \`a\` in the attached patch.
Sounds good.
>> Of course this may be dependent on the internals of the specific
>> regexp library at hand. I do not know enough to judge. In fact I
>> believe that a solid regular expression library should provide a
>> specific regular expression that matches nothing with special but
>> easy treatment that guarantees best response time.
> We could add a standard constant for it, like unmatchable-regexp, so
Yes, please. I'd recommend a `regexp-` prefix for it.
[ And I'll carefully avoid having an opinion on the rest of the name. ]
> that at least people don't keep reinventing it.
Not only that, but I'm pretty sure casual users will find it much easier
to understand what's going on when they see `regexp-<foo>` than when
they bump into "\\`a\\`". I.e. the constant's name should work as
a good comment.
Stefan
- regular expressions that match nothing, philippe schnoebelen, 2019/05/14
- Re: regular expressions that match nothing, Mattias Engdegård, 2019/05/14
- Re: regular expressions that match nothing,
Stefan Monnier <=
- Re: regular expressions that match nothing, Mattias Engdegård, 2019/05/15
- Re: regular expressions that match nothing, Alan Mackenzie, 2019/05/15
- Re: regular expressions that match nothing, Mattias Engdegård, 2019/05/16
- Re: regular expressions that match nothing, Phil Sainty, 2019/05/16
- Re: regular expressions that match nothing, Alan Mackenzie, 2019/05/17
- Re: regular expressions that match nothing, Mattias Engdegård, 2019/05/17
- Re: regular expressions that match nothing, Stefan Monnier, 2019/05/17
- Re: regular expressions that match nothing, Michael Heerdegen, 2019/05/15
- Re: regular expressions that match nothing, Stefan Monnier, 2019/05/15
- Re: regular expressions that match nothing, Mattias Engdegård, 2019/05/15