正则表达式c#:不包含子字符串但以_编号结尾的正则表达式
我想找到不包含子字符串(test、test、back、back、Down、Down)且以_编号结尾的字符串,例如正则表达式c#:不包含子字符串但以_编号结尾的正则表达式,c#,regex,numbers,substring,C#,Regex,Numbers,Substring,我想找到不包含子字符串(test、test、back、back、Down、Down)且以_编号结尾的字符串,例如 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|
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)
但它不起作用。似乎你想要这样的东西
^(?!.*?(?:[Tt]est|[Bb]ack|[Dd]own)).*?_\d+\.[^.\n]+$
使用负先行断言来匹配不包含特定子字符串的字符串
为什么
Down-05.txt
false?@anubhava,因为OP希望在数字之前有一个底部。不应该\u number
No-number
变为false,而且输入字符串也不包含子字符串Down。要查找字符串吗?根据您的陈述,“final\u 0
\n测试回退”将是正确的