如何在雪花中将 customer.value 更改为 "customer"."value"。删除字符串之间的 [],[0-9]

how to change customer.value to "customer"."value" in snowflake. which removes [,],[0-9] in between the string

create or replace procedure sp()
    returns VARCHAR
    language javascript
    as
    $$
    var A= ('Customers[0].value'.replace(/\[|\]|[0-9]/g,'')).replace(/(\w+)/g,'""');
    return A;
    $$;
call sp();
create or replace procedure sp() returns VARCHAR language javascript as 
$$ 
var A = 'Customers[0].value'.replace(/(\w+)\[[0-9]].(\w+)/g,'"".""');
return A; 
$$; 
call sp();

给出:

SP
"Customers"."value"

如果您要做的事情很多 Javascript,阅读 replace doc's 有助于了解不同的匹配类型,然后您可以按 F12 并使用网络浏览器控制台来test/debug 字符串,无需将其混搭成 SP 和 call/run 它。