Re: Bizarre behavior of \w in a regular expression bracket construct

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Joel Jacobson <joel(at)compiler(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Bizarre behavior of \w in a regular expression bracket construct
Date: 2021-02-21 16:06:51
Message-ID: 20210221160651.GA3721@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-Feb-21, Joel Jacobson wrote:

> regex | engine | deduced_ranges
> ------------+--------+-------------------------------
> ^([a-z])$ | pg | [a-z]
> ^([a-z])$ | pl | [a-z]
> ^([a-z])$ | v8 | [a-z]
> ^([\d-a])$ | pg |
> ^([\d-a])$ | pl | [-0-9a]
> ^([\d-a])$ | v8 | [-0-9a]
> ^([\w-;])$ | pg |
> ^([\w-;])$ | pl | [-0-9;A-Z_a-zªµºÀ-ÖØ-öø-ÿ]
> ^([\w-;])$ | v8 | [-0-9;A-Z_a-z]
> ^([\w-_])$ | pg | [0-9A-Z_a-zªµºÀ-ÖØ-öø-ÿ]
> ^([\w-_])$ | pl | [-0-9A-Z_a-zªµºÀ-ÖØ-öø-ÿ]
> ^([\w-_])$ | v8 | [-0-9A-Z_a-z]
> ^([\w])$ | pg | [0-9A-Z_a-zªµºÀ-ÖØ-öø-ÿ]
> ^([\w])$ | pl | [0-9A-Z_a-zªµºÀ-ÖØ-öø-ÿ]
> ^([\w])$ | v8 | [0-9A-Z_a-z]
> ^([\W])$ | pg |
> ^([\W])$ | pl | [\x01-/:-(at)[-^`{-©«-´¶-¹»-¿×÷]
> ^([\W])$ | v8 | [\x01-/:-(at)[-^`{-ÿ]
> ^([\w-a])$ | pg | [0-9A-Z_-zªµºÀ-ÖØ-öø-ÿ]
> ^([\w-a])$ | pl | [-0-9A-Z_a-zªµºÀ-ÖØ-öø-ÿ]
> ^([\w-a])$ | v8 | [-0-9A-Z_a-z]

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.

This one I didn't understand:
> ^([\W])$ | pg |

--
Álvaro Herrera Valdivia, Chile
"Porque francamente, si para saber manejarse a uno mismo hubiera que
rendir examen... ¿Quién es el machito que tendría carnet?" (Mafalda)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-02-21 17:39:45 Re: Bizarre behavior of \w in a regular expression bracket construct
Previous Message Justin Pryzby 2021-02-21 15:43:59 Re: Fallback table AM for relkinds without storage