Exclude a few words from a simple regex in PHP -


i'm categorizing few folders on drives , want weed out low quality files using regex (this works):

xvid|divx|480p|320p|divx|xvid|divx|xvid|xvid|divx|dvdscr|pdtv|pdtv|dvdrip|dvdrip|dvdrip 

now filenames in high definition still have dvd or xvid in filenames 1080p, 720p, 1080i or 720i. need single regex match 1 above exclude these words 1080p, 720p, 1080i or 720i.

you can use negative lookahead this

^(?!.*(?:1080p|720p|1080i|720i)).*(?:xvid|divx|480p|320p|divx|xvid|divx|xvid|xvid|divx|dvdscr|pdtv|pdtv|dvdrip|dvdrip|dvdrip) 

this match on search strings, fail if there 1080p|720p|1080i|720i in string.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -