Home > Net >  How to regexp_contains for a pattern text
How to regexp_contains for a pattern text

Time:01-13

I'm still newbie to Bigquery. I'm trying to get a data, if a field there is a string like:

> /a/arrow
> /b/bow
> /c/cheese
> /d/dog
> /e/edward
> /f/fruit
> ....
> /z/zebra

I've written:

WHEN
REGEXP_CONTAINS(LOWER(page_name),'/|^/a/|^/b/|^/c/|^/d/|^/e/|^/f/|^/g/|^/h/|^/i/|/^j/|^/k/|^/l/|^/m/|^/n/|^/o/|^/p|^/q/|^/r/|^/s/|^/t/|^/u/|^/v/|^/w/|^/x/|^/y/|^/z/') then 'library'

But it's still not working well, mixed with values other than those in the pattern. Can I get the correct value? thank you

Thank you in advance for the help!

CodePudding user response:

You can use

REGEXP_CONTAINS(entrance_page_name,'^/[a-z]/')

The regex matches

  • ^ - start of string
  • / - a / char
  • [a-z] - a lowercase ASCII letter
  • / - a / char.
  • Related