0

I am trying to extract a sample_type field from an URL that works in regular regex, but is not working in BigQuery

This regex works fine in the online tool at regex101.com: (?<=sample_type=)[\w_]+ to extract the word apple, but does not seem to apply to BQ. What is the correct way to get what is after sample_type for BQ?

SELECT REGEXP_EXTRACT('asdfasdfjsklfjasdf/info?sample_type=apple', r'sample_type=\w_+')

Wolf
  • 562
  • 1
  • 7
  • 19

1 Answers1

0

you should use sample_type=(\w+) as a regexpbelow as in below example

SELECT REGEXP_EXTRACT('asdfasdfjsklfjasdf/info?sample_type=apple', r'sample_type=(\w+)')
Mikhail Berlyant
  • 165,386
  • 8
  • 154
  • 230