> 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