Re: alternation option end of string
Alexis <[email protected]> Sun, 03 May 2026 14:33:12 +1000
| Newsgroups | gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <[email protected]> |
Ray Andrews <[email protected]> writes: > On 2026-05-02 15:25, Bart Schaefer wrote: >> It wouldn't have worked even if you were using a regular >> expression, >> for the same reason that (s|) didn't do what you want. In the >> comparison to the string "catszzz" the $ means the end of THAT >> string >> (that is, after the third "z"). It does NOT mean the "end of >> matching" up to that point. > But I would have expected > something like the $ usable as I'd intended. These semantics for `$` in regexes goes back to the 60s; cf. e.g. the "Addressing by dollar sign" section on the ninth page of this PDF: https://github.com/arnoldrobbins/qed-archive/blob/master/sds-940/901112B_940_QED_RefMan_Jan69.pdf There are different flavours of regex - POSIX BREs, POSIX EREs, PCREs, etc. - but i can't recall encountering a flavour where `$` doesn't have the semantics described by Bart. (i'd be interested to know if there is one.) Alexis.