我正在尝试省略一些字符来格式化我的字符串。我下面有示例字符串,想用','替换'/ [1-999] /'。
我一直在使用regexp_extract和regexp_replace,但是似乎没有任何作用。
select regexp_extract('/* 1 */{"key1" : "value1","key2" : "value2"}/* 2 */{"key1" : "value1","key2" : "value2"}','\/*\*','%');
我希望输出是
',{"key1" : "value1","key2" : "value2"},{"key1" : "value1","key2" : "value2"}'
答案 0 :(得分:0)
尝试使用此RegexDemo
使用python的示例:
text = '/* 1 */{"key1" : "value1","key2" : "value2"}/* 2 */{"key1" : "value1","key2" : "value2"}'
st = re.sub("(\/\*\s+\d+\s+\*\/)",",",text)
print (st)
输出:
,{"key1" : "value1","key2" : "value2"},{"key1" : "value1","key2" : "value2"}