[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Add some aliases for re-related functions
From: |
Stefan Monnier |
Subject: |
Re: Add some aliases for re-related functions |
Date: |
Sun, 03 May 2020 23:11:00 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
>> give you an automaton that can do the search or "RE" in O(n) time, but
>> it won't directly give you the "leftmost longest match" (instead it can
>> directly give you "the match whose match-end is closest" and "the match
>> whose match-end is furthest").
> But that's what we generally want in practice anyway.
Not according to POSIX and not according to the traditional behavior of
Emacs's regexp search.
>> Yes, it's unfortunate. Maybe we could/should merge them to clarify:
>> (re-match REGEXP &optional STRING LIMIT START)
>> (re-search REGEXP &optional STRING LIMIT START)
>> would be like `looking-at` but would operate on STRING instead of
>> `current-buffer` if STRING is non-nil. START defaults to point for
>> current-buffer and 0 for a string.
> re-search-forward also moves point, whereas string-match returns the index
> of the match start.
Oh, indeed, `re-search-forward` returns the match-end whereas
`string-match` returns the match start. I hate that difference.
> I'm not sure it's worth the changeover and retraining everybody
Agreed.
> if the main benefit is being more aware of the underlying
> algorithm complexity.
Not sure what this has to do with the algorithm complexity.
> It suppose so. Yet, in all cases I had to rewrite looking-back calls to add
> the now-mandatory argument, the resulting time it took was fast enough to
> get lost in the measurement noise.
Yes, the limit arg hides most of the performance problems, indeed.
Stefan
- Re: Add some aliases for re-related functions, (continued)
Re: Add some aliases for re-related functions, Stefan Monnier, 2020/05/02
- Re: Add some aliases for re-related functions, Dmitry Gutov, 2020/05/02
- Re: Add some aliases for re-related functions, Eric Abrahamsen, 2020/05/02
- Re: Add some aliases for re-related functions, Stefan Monnier, 2020/05/02
- Re: Add some aliases for re-related functions, Dmitry Gutov, 2020/05/02
- Re: Add some aliases for re-related functions, Stefan Monnier, 2020/05/02
- Re: Add some aliases for re-related functions, Dmitry Gutov, 2020/05/03
- Re: Add some aliases for re-related functions,
Stefan Monnier <=
RE: Add some aliases for re-related functions, Drew Adams, 2020/05/02
- Re: Add some aliases for re-related functions, Stefan Monnier, 2020/05/02
- RE: Add some aliases for re-related functions, Drew Adams, 2020/05/03
- Re: Add some aliases for re-related functions, Philippe Vaucher, 2020/05/03
- Re: Add some aliases for re-related functions, Alan Mackenzie, 2020/05/03
- Re: Add some aliases for re-related functions, tomas, 2020/05/03
- Re: Add some aliases for re-related functions, Eli Zaretskii, 2020/05/03
RE: Add some aliases for re-related functions, Drew Adams, 2020/05/03
Re: Add some aliases for re-related functions, Philippe Vaucher, 2020/05/04
Sending plaintext with Gmail (was: Add some aliases for re-related functions), Kévin Le Gouguec, 2020/05/04