Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Pattern engine extension for \< and \> support?
- X-seq: zsh-workers 51336
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Pattern engine extension for \< and \> support?
- Date: Fri, 27 Jan 2023 18:48:14 +0000
- Archived-at: <https://zsh.org/workers/51336>
- Feedback-id: i425e4195:Fastmail
- In-reply-to: <CAKc7PVCAf0roQXYK-_1HD4OGcPVPzd+474=T=5EKMV3uXDTZ-Q@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAKc7PVCAf0roQXYK-_1HD4OGcPVPzd+474=T=5EKMV3uXDTZ-Q@mail.gmail.com>
Sebastian Gniazdowski wrote on Fri, Jan 27, 2023 at 10:01:15 +0000:
> Hi,
> in regexps, there are \<, \> and also \b sequences, that match zero-length
> string on the word boundary. They are particularly useful for e.g.:
> refactoring substitutions, like e.g.: with sed:
>
> sed -r -i -e 's/\<myvar\>/other/'
>
> This automatically protects pre/suffixed strings like str_myvar and
> myvar_str. In mcedit, I often use \b that's available there (\< and \> do
> not work), to obtain the same effect with the regex:
>
> \bmyvat\b
>
> I'm not sure if distinction of left and right boundary offered by \<, \>
> actually makes a difference.
>
> Zsh has similar sequences already - (#s) and (#e). They do match 0=length
> strings on begin or end of the matched string. So maybe the topic is known
> to any implementing person? Is it hard to add such \b or \<,\> sequences?
> Could it be also possible to make it backward-safe, i.e. the sequence be
> ignored by proceeding Zsh versions?
This happens to be covered here:
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/regexp.md
tl;dr For portability use RE_MATCH_PCRE.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author