I am using UDF to do a little regex for phrase like 'test/test' and I came across an error that I can't correct.
CREATE TEMPORARY FUNCTION parseMethod(queryString STRING)
RETURNS STRING
LANGUAGE js AS
\"\"\"
var match_regex = /test\/(\w+)/i;
var found_method;
if(found_method = queryString.match(match_regex)){
method_list = found_method[1];
}
return method_list;
\"\"\";
SELECT
parseMethod('test/test') AS result
When I run this code, I get an error saying
Error in query string: Error processing job
'click-1315:XXXXXXXX': Syntax error:
Illegal escape sequence: \/
The javascript function works fine in node.js so I am guessing parsing of BigQuery doesn't like this format. I also tried \\/
but same error. How can I fix this?