0

I would to like to replace a letter in a string by position in big query. for example XXXXX, YYYYY, ZZZZZ the 5th letter in the string to 0 I've tried to use the Stuff function, but big query doesn't find the function Stuff(XXXXX, 5, 1, '0')

4

2 回答 2

1

可能最简单的方法是更基本的字符串操作:

select concat(substr(x, 1, 4), '0', substr(x, 6))
于 2018-07-29T15:28:05.260 回答
0

以下是 BigQuery 标准 SQL 和旧版 SQL(两者都适用)

SELECT REGEXP_REPLACE(str, r'(.{4}).(.*)', r'\10\2')
于 2018-07-29T16:33:41.063 回答