From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Joel Jacobson <joel@compiler.org>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Bizarre behavior of \w in a regular expression bracket construct
Date: Sun, 21 Feb 2021 12:39:45 -0500
Message-ID: <3467328.1613929185@sss.pgh.pa.us> (raw)
In-Reply-To: <20210221160651.GA3721@alvherre.pgsql>
References: <20210221160651.GA3721@alvherre.pgsql>
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> It looks like the interpretation of these other engines is that [\d-a]
> is the set of \d, the literal character "-", and the literal character
> "a". In other words, the - preceded by \d or \w (or any other character
> class, I guess?) loses its special meaning of identifying a character
> range.
Yeah. While I can see the attraction of being picky about this,
I can also see the attraction of being more compatible with other
engines. Should we relax this?
A quick experiment with perl shows that its opinion is "if the
atom before or after a potentially range-defining dash is a
character class, then take the dash as an ordinary character".
(This confirms Joel's result, and also I found that e.g. [3-\w]
treats the dash as a literal character.)
> This one I didn't understand:
>> ^([\W])$ | pg |
I think Joel just forgot to mark that as ERROR. It certainly
doesn't work in our engine today (though I'm nearly done with
a patch to fix that).
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, alvherre@alvh.no-ip.org, joel@compiler.org
Subject: Re: Bizarre behavior of \w in a regular expression bracket construct
In-Reply-To: <3467328.1613929185@sss.pgh.pa.us>
References: <20210221160651.GA3721@alvherre.pgsql> <3467328.1613929185@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox