Regexp extract to match number of 8 digits after a known string in BigQuery
I need to extract 8 digits after a known string:
\n\n| MyString | Extract: | \n| ---------------------------- | -------- | \n| mypasswordis 12345678 | 12345678 | \n| # mypasswordis 12345678 | 12345678 | \n| foobar mypasswordis 12345678 | 12345678 |\n
\n\nSolution:
Use
SELECT REGEXP_EXTRACT(MyString, r"mypasswordis\s*([0-9]{8})"))\n
\n\nOr just
\n\nSELECT REGEXP_EXTRACT(MyString, r"mypasswordis\s*([0-9]+)"))
mCollins
posted onEnjoy 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
Post Comment