简体   繁体   English

负正则表达式,用于查找不包含某些字符的文本

[英]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" “用以下文本查找所有文件但不以.zip或.md5结尾的所有文件”的正则表达式是什么?

So I have 3 files: 所以我有3个文件:

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. 我想选择中间文件test-2016-123并忽略具有.zip或.md5等文件扩展名的文件。

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 我不是Regex专家,但(^test).((?!(zip|md5)$).)*$可以匹配任何其他扩展名,如果在这种情况下您可以使用.txt,.pdf之类的文本这个试试这个

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

this will ignore all of extension and give You proper match .. 这将忽略所有扩展名,并为您提供适当的匹配..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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