I have the following string:
'AAA|BBB||CCC|1.23'
I would like to return: 'CCC|1.23'
When using the regexp: \w+\|\d(.\d+|$) I am able to get the desired results.
When in Snowflake running the following query, returns the correct results:
SELECT REGEXP_SUBSTR('AAA|BBB||CCC|1.23', '\\w+\\|\\d(.\\d+|$)') AS regexp_return;
However when used in a stored procedure as follows:
CREATE OR REPLACE PROCEDURE dnr.regexp_issue ()
returns string
language javascript
execute as owner
AS
$$
var sql_statement = `SELECT REGEXP_SUBSTR('AAA|BBB||CCC|1.23', '\\w+\\|\\d(.\\d+|$)') AS regexp_return;`
var query = snowflake.createStatement({sqlText: sql_statement});
var query_res = query.execute();
query_res.next();
result = query_res.getColumnValue(1);
return result;
$$;
The resulting CALL dnr.regexp_issue(); returns a NULL as if no matching pattern was found.
Any ideas?