开发者

RegEx split combine successive result .net

I need to split a string based on connectors which can be and or not etc. For ex:

col1 contains test and not col1 contains test1

I'm using (and|or)[ ](\bnot\b[ ])?

It splits correctly but开发者_开发知识库 however I want both and not to be under single split. Currently split returns me And in one array and Not as next array value.


You can use string.Split("and not"); Or am I missing somthing?


My guess is that you are looking for something like:

\b((?:and|or)(?: not)?)\b

Or if you want to handle variable white space:

\s*\b((?:and|or)(?:\s+not)?)\b\s*
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜