How to remove only letters from a string in BigQuery?

For example:

\n\n
XXXX123456\nAAAA123456789\nXYZR12345678\nABCD1234567\n1111\n2222\n
\n\n

I want the end result to look like:

\n\n
123456\n123456789\n12345678\n1234567\n1111\n2222\n
\n\n

Solution:

You can use regexp_replace():

\n\n
select regexp_replace(str, '[^0-9]', '')\n

DataFreak

posted on

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds