2014-11-05 242 views
0

结束,我想找到一种不包含子(测试,测试,退后,退后,下来,下来),并与_number例如结束串正则表达式C#:正则表达式,不包含子串,但与_number

test_02.txt -- False 
Final_test_02.txt -- False 
final_02.txt -- True 
final_3.txt -- True 
final_17.txt -- True 
Down-05.txt -- False 

如何使用正则表达式有效地执行此操作。我是RegEx的新手。我试过

((.*)^(test|Test|back|Back|Down)(.*)_\d) 

但它不工作。

+0

为什么'Down-05.txt'为false? – anubhava 2014-11-05 15:36:42

+0

@anubhava由于OP想要下划线号码前。 – 2014-11-05 15:37:05

+0

不应该'_number'没有'-number'成为假 – anubhava 2014-11-05 15:38:06

回答

2

好像你想是这样的,

^(?!.*?(?:[Tt]est|[Bb]ack|[Dd]own)).*?_\d+\.[^.\n]+$ 

使用式断言,以匹配其将不包含特定的子字符串。

DEMO