Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to extract string between "+" and "@" from column in Presto?

I have table in Presto like below:

Input data:

PHONE_NUMBER
--------
ppa:+77845678021@abc.gbc443.gbc356.7kffooopppp.deu  
tel:+77695002395  
dadsadas+884415002996xx2
....

Requirements:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading