Re: order of (escaped) characters in regex range - Mailing list pgsql-general

From Rob Marjot
Subject Re: order of (escaped) characters in regex range
Date
Msg-id CA+DVeYDsbxgoyHkxZJRxt2A7rxXo2ESJ2cxXMZ+Hf1zP+2WoUg@mail.gmail.com
Whole thread Raw
In response to Re: order of (escaped) characters in regex range  (Szymon Guz <mabewlun@gmail.com>)
List pgsql-general
True, but still weird...

And are you sure it does the same thing?

2011/12/13 Szymon Guz <mabewlun@gmail.com>


On 13 December 2011 14:04, InterRob <rob.marjot@gmail.com> wrote:
Dear List,

I found this interesting:

SELECT regexp_matches('123-A' , E'(3[A-Z\- ])');
ERROR:  invalid regular expression: invalid character range

whereas:
SELECT regexp_matches('123-A' , E'(3[\- A-Z])');
 regexp_matches
----------------
 {3-}
(1 row)

Notice the order of (escaped) characters and ranges in the last bit of the expression.

Am I missing some key concept of the regular expression?

Regards,
Rob

Hi Rob,
try '\\-' instead of '\-'
and it works :)

regards
Szymon

pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: order of (escaped) characters in regex range
Next
From: anisoptera
Date:
Subject: query for all values linked to a field