| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: regex Quantifiers {m,n}, m can be negative, n greater than 255 |
| Date: | 2025-12-11 15:46:54 |
| Message-ID: | 831833.1765468014@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
jian he <jian(dot)universality(at)gmail(dot)com> writes:
> select regexp_matches(E'abc', 'a{0,257}.');
> select regexp_matches(E'abc', 'a{-0,257}.');
> select regexp_matches(E'abc', 'a{-1,2}.');
> based on the manual description, the second and the third query should
> error out?
No. Read
https://www.postgresql.org/docs/current/functions-matching.html#POSIX-ATOMS-TABLE
which says that '{'
when followed by a character other than a digit, matches the
left-brace character {; when followed by a digit, it is the
beginning of a bound (see below)
So your second and third patterns are just literal matches, except
for the final '.'.
You can quibble about how bright that choice was, but I think it's
mandated by POSIX, not just something that Henry Spencer thought up.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2025-12-11 16:05:12 | Re: [PATCH] Fix severe performance regression with gettext 0.20+ on Windows |
| Previous Message | Andres Freund | 2025-12-11 15:39:55 | Re: Fix and improve allocation formulas |