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
The character '\' is a special character and needs to be escaped when used as part of a String, e.g., "\". Here is an example of a string comparison using the '\' character: if (invName. substring(j,k).
Generally speaking, when the compiler gives you an error message, it tells you more than just "illegal escape character". It will show you the line and even the exact spot it thinks the error actually is: ? It GREATLY helps people help you if you post the ENTIRE message.
Use regexp_contains((cs_user_agent), r'^AppleCoreMedia\/1\.(.*)iPod')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With