簡體   English   中英

RegEx C#:不包含子字符串但以_Number結尾的正則表達式

[英]RegEx c#: regex expression that does not contain substring but ends with _Number

我想找到不包含子字符串(test,Test,back,Back,Down,down)的字符串,並且以_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)

但這是行不通的。

好像您想要這樣的東西,

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

使用否定的超前斷言來匹配不包含特定子字符串的字符串。

演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM