Regex选择NOT和操作数



我正在尝试使用C#中的Regex将字符串分解为数组。例如,我有字符串

 {([Field] = '100' OR [LaneDescription] LIKE '%DENTINPALEUW%' 
 OR [LaneDescription] = 'asdf' OR ([ObjectID] = 1) AND [ITEM_HEIGHT] >= 
 10 AND [SENDER_COMPANY] NOT LIKE '%DHL%'}

(由Telerik RadFilter生成)

我需要将它断开,这样我就可以将它传递给具有以下类型的自定义对象:左括号、字段、比较器、值、右括号。

到目前为止,在http://regexr.com我已经联系到

[([^[]]*)]+|[w'%]+|[()=] 

但我需要将">="one_answers"NOT LIKE"作为一个(以及类似的值,如<>!=等)

你可以看到我在深夜尝试http://regexr.com/39g6b

任何帮助都将不胜感激。

(PS:字符串中没有换行符)

尝试

(|)|[[a-zA-Z0-9_]+]|'.*?'|d+|NOT LIKE|w+|[=><!]+

演示。

说明:

    ( // match "(" literally
    | // or
    ) // ")"
    | // or
    [[a-zA-Z0-9_]+] // any words inside square braces []
    |
    '.*?' // strings enclosed in single quotes '' (escape sequences can easily trip this up though)
    |
    d+ // digits
    |
    NOT LIKE // "NOT LIKE", because this is the only token that can contain whitespace
    |
    w+ // words like "NOT", "AND", etc
    |
    [=><!]+ // operators like ">", "!=", etc

最新更新