如何用正则匹配后缀名不为.jpg, .css, .js, .html, .htm, .png的文件

有网友碰到过这样的问题:如何用正则匹配后缀名不为.jpg, .css, .js, .html, .htm, .png的文件,问题详细内容为:php

如何用正则匹配后缀名不为.jpg, .css, .js, .html, .htm, .png的文件 ?css

 

,我搜你经过互联网收集了相关的一些解决方案,但愿对有过相同或者类似问题的网友提供帮助,具体以下:

解决方案1:
html

/.*\.(?:(?!(jpg|css|js|html|htm|png)).)+/ 

 

--- 共有 3 条评论 ---正则表达式

  • 皮总find . -type f -name "*.odt" -o -name "*.exe"(4年前)  回复
  • 皮总find 是不支付这种复杂正则的(4年前)  回复
  • 爱国者find /usr/local/apache2/htdocs -type f -regex '.*\.(?:(?!(jpg|css|js|html|htm|png)).)+' 好像不work(4年前)  回复


解决方案2:
apache

here you go...spa

find . -type f \( ! -iname "*.css" ! -iname "*.png" ! -iname "*.jpg" ! -iname "*.js" ! -iname "*.html" ! -iname "*.htm" \)htm

 

正则表达式 判断文件名后缀是否为 csv xls xlsx

/\.(?:csv|xls|xlsx)$/iSystem.out.println("abc.jpg".matches(".*\\.(?i)jpg"));
相关文章
相关标签/搜索