I have table in Presto like below:
Input data:
PHONE_NUMBER
--------
ppa:+77845678021@abc.gbc443.gbc356.7kffooopppp.deu
tel:+77695002395
dadsadas+884415002996xx2
....
Requirements:
And I need to take all values from column "PHONE_NUMBER" between "+" and "@" (if exists).
Desire output:
So, as a result I need something like below:
PHONE_NUMBER
--------
77845678021
77695002395
884415002996
....
How can I do that in Presto ?
>Solution :
I believe for this version of a question you could use something like this:
SELECT regexp_extract(PHONE_NUMBER, '\+(\d+)@?', 1) from my_table;
Here from PHONE_NUMBER of every row will be extracted digits, that immediately follow plus sign, and optionally followed by @.
If you has some understanding of how much digits is expected, you could use \+(\d{13,146})@?, where 13 – minimum number of digits (including), 146 – maximum (including).