简体   繁体   中英

Negative regex for finding text which do not contain certain characters

What is the regex for "Find me all the files with the following text but not ending with .zip or .md5"

So I have 3 files:

test-2016-123.zip......zip file
test-2016-123..........directory file
test-2016-123.MD5......checksum file

I want to select the middle file test-2016-123 and want to ignore file with file extentions like .zip or .md5 etc.

What would be the regular expression to accomplish this?

So far I have something like this:

test-*+[^.\]

But this obviously does not work. Any help will be appreciated.

试试这个(^test).((?!(zip|md5)$).)*$

I am not expert in Regex but in (^test).((?!(zip|md5)$).)*$ will match any other extension if there are in text like .txt , .pdf in that condition you can Use this one Try this

^test-(\w+\-(\w+)$)

this will ignore all of extension and give You proper match ..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM