What is the meaning of r in REGEXP_EXTRACT (word, r '(\ w \ w \' \ w \ w) ')

I cannot find the answer in the BigQuery Reference or re2 wiki .

In all examples for the Regex section in the BigQuery manual, there is an “r” before each regular expression, but I can’t find the point in it. For instance:

REGEXP_EXTRACT (word, r '(\ w \ w \' \ w \ w) ')

It seems to me that this is a type of "regex" or something else, because it allows "\" and "" in the next line.

Thanks to everyone who knows and sends the answer to this question :)

+4
source share
1 answer

" , - , . ".

http://en.wikipedia.org/wiki/String_literal#Raw_strings

, , escape- :

SELECT REGEXP_EXTRACT("ab'cd", '(\w\w\'\w\w)') 

Error: Invalid string literal: '(\w\w\'\w\w)'

. :

:

SELECT REGEXP_EXTRACT("ab'cd", '(\\w\\w\'\\w\\w)')
ab'cd

:

SELECT REGEXP_EXTRACT("ab'cd", r'(\w\w\'\w\w)')
ab'cd
+9

All Articles