我想从字符串中删除 /**/ 之间的字符
例子:
转换字符串
“select * from food where /* id = 1 and */ food_code = 2”
到
“从 food_code = 2 的食物中选择 *”
可以这样做
select regexp_replace('select * from food where /* id = 1 and */ food_code = 2', '\/\*.+\*\/', '','g');
转义“/”和“*”。
我们可以使用积极的后视
(?<=re)
和积极的前瞻(?=re)
这将捕获并删除多个 /.+/
select regexp_replace(string, '\/\*(?<=\/\*)(.*?)(?=\*\/)\*\/','', 'g')
from mytable
任何人都可以帮助我......................?