kshoe94
kshoe94

Reputation: 429

BigQuery - Illegal Escape Sequence

I'm having an issue matching regular expression in BigQuery. I have the following line of code that tries to identify user agents:

when regexp_contains((cs_user_agent),  '^AppleCoreMedia\/1\.(.*)iPod') then "iOS App - iPod"

However, BigQuery doesn't seem to like escape sequences for some reason and I get this error that I can't figure out:

Syntax error: Illegal escape sequence: \/ at [4:63]

This code works fine in a regex validator I use, but BigQuery is unhappy with it and I can't figure out why. Thanks in advance for the help

Upvotes: 13

Views: 21663

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172993

Use regexp_contains((cs_user_agent), r'^AppleCoreMedia\/1\.(.*)iPod')

Upvotes: 31

Related Questions