Re: Control PhoneNumber Via SQL - Mailing list pgsql-general

From David G. Johnston
Subject Re: Control PhoneNumber Via SQL
Date
Msg-id CAKFQuwbWLDHPx4kh18O4N1YJ1BgLtxp4e1JonX2gtKTmqbcWWw@mail.gmail.com
Whole thread Raw
In response to Re: Control PhoneNumber Via SQL  (tango ward <tangoward15@gmail.com>)
Responses Re: Control PhoneNumber Via SQL  (tango ward <tangoward15@gmail.com>)
List pgsql-general
On Tuesday, May 15, 2018, tango ward <tangoward15@gmail.com> wrote:
Sorry for bumping this email.

I would just like to clarify regarding regexp_replace:

WHEN mobilenumber ~'^9[0-9]' AND LENGTH(mobilenumber) = 10
THEN regexp_replace(mobilenumber, '', '+63')

If the pattern is empty '', does this mean that the replacement_string param will be added to the value of source? It does what I want it to do but I am not sure if that's always the case if pattern param is empty.

If you could bottom-post like the rest of us that would be helpful.

While that seems to work it is definitely obscure.  You should just use concatenation.

’+63' || mobilenumber

The pattern is a zero-length string, matched once, which first matches the start of the input text.  Not sure what happens when the input is the empty string...

David J.

pgsql-general by date:

Previous
From: tango ward
Date:
Subject: Re: Control PhoneNumber Via SQL
Next
From: tango ward
Date:
Subject: Re: Control PhoneNumber Via SQL