Google bigquery 解码为希伯来语时不正确的regex_替换
下面的代码不起作用,因为我的regex_replace没有处理应该处理的空格。帮助 创建临时函数 将字符串解码为 选择 如果 以单词“&x”开头, safe.code\u指向\u字符串数组 选择 输入值为int64 从…起 UNNESTSPLITREPLACEREGEXP_REPLACEword“[^a-zA-Z0-9&]”、“&”、“0”和“;”价值 哪里 非值=, 单词 具有 数据作为 选择 &x5E9&x5D1&x5D7&x5D9&x5DD&x5DC&x5E1&x5D5&x5E7&x5D5&x5DC&x5D5&x5D1&x5E1&x5E7&x5D9&x5D4&x5D0&x5E8&x5D9&x5E1;:&x5D9&x5D3&x5E2&x5E0&x5D5&x5E9&x5EA&x5D4&x5D9&x5D4&x5DE&x5DC&x5D7&x5DE&x5D4;'文本 选择 选择 字串 从…起 UNNESTSPLITtxt,“单词为希伯来文” 从…起 数据 预期结果:1、1、2、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、3、4、4、4、4、4、4、4、4、4、4、5Google bigquery 解码为希伯来语时不正确的regex_替换,google-bigquery,Google Bigquery,下面的代码不起作用,因为我的regex_replace没有处理应该处理的空格。帮助 创建临时函数 将字符串解码为 选择 如果 以单词“&x”开头, safe.code\u指向\u字符串数组 选择 输入值为int64 从…起 UNNESTSPLITREPLACEREGEXP_REPLACEword“[^a-zA-Z0-9&]”、“&”、“0”和“;”价值 哪里 非值=, 单词 具有 数据作为 选择 &x5E9&x5D1&x5D7&x5D9&x5DD&x5DC&x5E1&x5D5&x5E7&x5D5
create temp function decode(word string) as ((
select if(starts_with(word, '&#x'),
safe.code_points_to_string(array(
select ifnull(safe_cast(value as int64), ascii(value))
from unnest(split(replace(word, '&#', '0'),';')) value
where not value = ''
)),
word)
));
select (
select string_agg(decode(word), ' ')
from unnest(split(txt, ' ')) word
) as Hebrew_txt
from data
如果应用于问题中的样本数据,则输出为