Re: BUG #15756: Seemingly inconsistent behavior of SUBSTRING(stringFROM pattern FOR escape) function - Mailing list pgsql-bugs

From Daniel Gustafsson
Subject Re: BUG #15756: Seemingly inconsistent behavior of SUBSTRING(stringFROM pattern FOR escape) function
Date
Msg-id AB69E15A-AE09-4041-B0C1-01F2989C4014@pivotal.io
Whole thread Raw
In response to BUG #15756: Seemingly inconsistent behavior of SUBSTRING(string FROM pattern FOR escape) function  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
> On 15 Apr 2019, at 12:01, PG Bug reporting form <noreply@postgresql.org> wrote:

> The latter function invocation
> permanently returns NULL value that can be easily seen when wrapped in
> COALESCE:
> psql --username=postgres --no-password --command="SELECT
> COALESCE(SUBSTRING('+380481234567' FROM '%#"[0-9]{9}#"' FOR '#'), 'NULL’)"

When executing this in a shell, I believe you need to escape the quotes in the
query.  The below commandline seems to work fine for me (tested in 9.4 and
current master):

$ ./bin/psql --command=“SELECT COALESCE(SUBSTRING('+380481234567' FROM '%#\"[0-9]{9}#\"' FOR '#'), 'NULL')" postgres
 coalesce
-----------
 481234567
(1 row)

cheers ./daniel


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #15756: Seemingly inconsistent behavior of SUBSTRING(string FROM pattern FOR escape) function
Next
From: Francisco Olarte
Date:
Subject: Re: BUG #15756: Seemingly inconsistent behavior of SUBSTRING(stringFROM pattern FOR escape) function