加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式 将SQL条件的左边字段和右边值分别取出来

发布时间:2020-12-14 01:13:00 所属栏目:百科 来源:网络整理
导读:sql事例:select * from table1 where a1=221 and b2=33 and c3 in (1,2,3) and d544 and (e1=6 or f2=8) 正则: ([^()s]+)(?:[=]{1,2}|s*ins*)(?a()?([^()s]+)(?(a))) 或者: (w+)(?:=|in(|)([d,]+) 匹配等号左右两边有空格的情况: ([^()s]+)s*

sql事例:select * from table1 where a1=221 and b2=33 and c3 in (1,2,3) and d5<44 and (e1=6 or f2=8)


正则: ([^()s]+)(?:[=<>]{1,2}|s*ins*)(?<a>()?([^()s]+)(?(a)))

或者: (w+)(?:=|in(|<)([d,]+)


匹配等号左右两边有空格的情况: ([^()s]+)s*(?:[=<>]{1,2}|s*ins*)s*(?<a>()?([^()s;]+)(?(a)))


继续改进:([^()s]+)s*(?>[=<>]{1,2}|in|like)s*(?<a>()?((?(a)[^;.()]+|[^s;.()]+)(?<b>()?(?(b)[^;.()]*|[^s;.()]*)(?(b))))(?(a)))(?=[s)])[s)]*(and|or)?b


都是大神的杰作,仅供参考!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读