Re: Using POSIX Regular Expressions on xml type fields gives inconsistent results - Mailing list pgsql-general

From Tom Lane
Subject Re: Using POSIX Regular Expressions on xml type fields gives inconsistent results
Date
Msg-id 16085.1356106091@sss.pgh.pa.us
Whole thread Raw
In response to Re: Using POSIX Regular Expressions on xml type fields gives inconsistent results  (Denis Papathanasiou <denis.papathanasiou@banrai.com>)
List pgsql-general
Denis Papathanasiou <denis.papathanasiou@banrai.com> writes:
> I did realize that ANY() must be a right-hand operator, but what I
> didn't understand (and admittedly still don't understand) is why regex
> operations that are normally right-side work from the left.

All regex operators in Postgres have the pattern on the right.  This
follows the lead of the SQL standard's LIKE operator, which has its
pattern on the right.  You might be used to some other language that
puts the pattern on the left, but that isn't some kind of natural law.
And it most certainly isn't the case that the operator will look at the
two text strings and try to guess which one is meant as a pattern.  That
would be impossibly unreliable.

> If you look at the four examples which follow the posix match table in
> the docs
> (http://www.postgresql.org/docs/9.1/static/functions-matching.html#FUNCTIONS-POSIX-TABLE),
> some of them work from the left side, e.g.:

Not to my eyes ...

            regards, tom lane


pgsql-general by date:

Previous
From: "David Johnston"
Date:
Subject: Re: Using POSIX Regular Expressions on xml type fields gives inconsistent results
Next
From: Chris Angelico
Date:
Subject: Re: Coalesce bug ?