正则表达式不包含

时间:2014-12-14 23:13:33

标签: regex c#-4.0

在SO上问过几次,但是我不能让我去上班 C#中的正则表达式 我想搜索像这个模板

这样的文字
xxx yyy(zzz)  

其中x,y,z可以是a-z,A-Z,0-9。

  • 不应在 xxx 部分
  • 中包含范围
  • 仅在 zzz 部分
  • 中包含已完成
  • yyy 部分
  • 中仅包含状态

匹配的文字
testscope status(done)
devscope status(wait)
retest status(done), dev1scope status(wait)

如突出显示,我只想找到重新测试状态(已完成)

enter image description here

3 个答案:

答案 0 :(得分:0)

尝试:

[^(范围)] +([]状态[(]完成[)])

[^(范围)] + - 除“范围”以外的任何字符序列;

([] status [(] done [)]) - 字符串'状态(已完成)'

答案 1 :(得分:0)

这样的事可能

 #  @"\b(?!\w*scope)[^\W_]+[ \t]status\(done\)"

 \b                     # Word boundry so s'cope' is not matched
 (?! \w* scope )        # Not 'scope' ahead
 [^\W_]+                # Words, not underscore
 [ \t]                  # Single tab or space
 status\(done\)         # 'status(done)'

答案 2 :(得分:0)

这对我有用

\b(?<!scope)[ \t]+status\(done\).*