-1

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
  • 552
  • 7
  • 18

1 Answers1

-1

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
  • 117,385
  • 6
  • 77
  • 139