RexEx 与上一组不匹配

RexEx not matching the last group

提问人:binks 提问时间:10/29/2023 更新时间:10/29/2023 访问量:60

问:

我有以下正则表达式

(.*?)(>=|<=|~|!=|=|!~|>|<| IS | IS NOT | WAS | WAS IN | WAS NOT | WAS NOT IN | CHANGED | OR | AND | IN | NOT IN )

它几乎与我所有的测试文本相匹配:

project=blah AND blah=something OR issuetype!="blah" AND someissue IN somefunction("blah") OR blahing <= "something"

它只是与最后一个“某物”字符串不匹配。我明白为什么,但我正在努力在表达式中加入一些东西来捕捉最终值。

C# 正则表达式

评论

3赞 flq 10/29/2023
就像切线一样 - 您似乎正在尝试解析 SQL。快速搜索显示,.NET 有强大的 SQL 解析器,这可能是解决问题的更好的长期方法。
0赞 sln 10/29/2023
例如,这是否意味着它需要在 之前和之后有一个空格。同样,其他文本更改?| WAS NOT IN |WAS NOT IN

答:

0赞 binks 10/29/2023 #1

我认为似乎已经成功了

((.*?)(>=|<=|~|!=|=|!~|>|<| IS | IS NOT | WAS | WAS IN | WAS NOT | WAS NOT IN | CHANGED | OR | AND | IN | NOT IN ))|(.*?)$