I have filter string like
"(empID = 10) AND (age IN ('10', '12', '2')) OR name NOT IN ( 'eq', 'test') AND (name='Gorge')"
I just want to replace the "IN ("
to "IN ["
so my final string filter string will be like this
"(empID = 10) AND (age IN ['10', '12', '2']) OR name NOT IN [ 'eq', 'test'] AND (name='Gorge')"
Can anyone help me for what will be my regular expression for above filter string.
答案 0 :(得分:0)
对于简单的情况,您可以尝试:
(IN\s+)\((.*?)\)
(替换为$1[$2]
匹配)
演示:https://regex101.com/r/Ss4tVA/1
但通常不使用Regexes来解析SQL(片段)。考虑使用完整的解析器。