简体   繁体   中英

regular expression to ignore file extension pattern xxx.html vs xxx.prod.html

I have a few directories to extract files. I only want the .prod files:

Example

src
 - dir1
   -- file1.prod.html
   -- file1.html
   -- file2.prod.html
   -- file2.html
 - dir2
-- filex.prod.html
-- filex.html
-- filen.prod.html
-- filen.html

I would like exclude all .html (but not .prod.html )

expected results:

src
     - dir1
       -- file1.prod.html
       -- file2.prod.html
     - dir2
       -- filex.prod.html
       -- filen.prod.html




   ((?!.html).prod.html$)

If you want to match strings ending on .prod.html you don't need a lookahead:

^.+\.prod\.html$

Regex demo

I might be making this too simple, but since the base .html files do not contain .prod you could just key on that. Try: .*\\.prod.*

我认为这可以解决问题:

^((\.prod\.html)|(?!html).)*$

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