1

How can I match all images without thumb image using regexp ?

hi.gif
thumb.gif
hello.gif

Result should be :

hi.gif
hello.gif

I am using .+(gif|GIF|jpg|JPG) to match all images

codaddict
  • 445,704
  • 82
  • 492
  • 529
faressoft
  • 19,053
  • 44
  • 104
  • 146

3 Answers3

2

You can use -ve lookahead assertion as:

^(?!thumb).+\.(?:gif|GIF|jpg|JPG)$

Rubular link

Regexr link

codaddict
  • 445,704
  • 82
  • 492
  • 529
0

Put a negative look-ahead at the start:

(?!thumb\.).+(gif|GIF|jpg|JPG)
Guffa
  • 687,336
  • 108
  • 737
  • 1,005
-1

You can use this regex:

.+(?<!^thumb)\..+$

Also add options Multiline.

arena-ru
  • 990
  • 2
  • 12
  • 25