Ray Andrews <rayandrews@xxxxxxxxxxx> 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 thecomparison 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.pdfThere 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.