[PATCH] regex: Add \A and \z synonyms to \` and \'

Paul Eggert eggert@cs.ucla.edu
Thu May 1 20:28:51 GMT 2025


On 2025-05-01 08:15, Eric Blake wrote:
> If POSIX were to try to standardize \` and \' instead of \A and \z, it
> would have the benefit of existing practice (glibc), but the drawback
> of less familiarity (lots more languages would have to adapt, whereas
> now \A is fairly common and \` is rare).

I don't know, propagating confusion of \z vs \Z sounds backwards to me.

Python is the biggest dog in the zoo right now, and regardless of 
whether the proposed glibc patch is applied, Python would have to change 
for it to be compatible with glibc. So why not stick with something that 
is both intuitive and has seen widespread use?

\A...\Z (Python) is intuitive but is not upward compatible with Perl so 
OK, that's out.  Although \`...\' (glibc) and \A...\z (Perl) are both 
upward compatible the other alternatives, \A...\z is confusing whereas 
\`...\' is intuitive. Let's stick with the intuitive approach, in both 
glibc and POSIX.


> If POSIX were to try to standardize \` and \' instead of \A and \z, it
> would have the benefit of existing practice (glibc)

Not just glibc. A quick search shows that FreeBSD[1] and Boost[2][3] 
both support \`...\' in POSIX-style BREs and EREs, as an extension. 
Surely there are other implementations.

Let's standardize what already works instead of adding even more confusion.

[1]: 
https://github.com/freebsd/freebsd-src/commit/ca53e5aedfebcc1b4091b68e01b2d5cae923f85e
[2]: 
https://www.boost.org/doc/libs/1_88_0/libs/regex/doc/html/boost_regex/syntax/basic_syntax.html
[3]: 
https://www.boost.org/doc/libs/1_88_0/libs/regex/doc/html/boost_regex/syntax/basic_extended.html


More information about the Libc-alpha mailing list