如何用正則匹配後綴名不爲.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"));
相關文章
相關標籤/搜索