How can I match all images without thumb image using regexp
How can I match all images without thumb image using regexp ?
hi.gif开发者_C百科
thumb.gif
hello.gif
Result should be :
hi.gif
hello.gif
I am using .+(gif|GIF|jpg|JPG)
to match all images
You can use -ve lookahead assertion as:
^(?!thumb).+\.(?:gif|GIF|jpg|JPG)$
Rubular link
Regexr link
Put a negative look-ahead at the start:
(?!thumb\.).+(gif|GIF|jpg|JPG)
You can use this regex:
.+(?<!^thumb)\..+$
Also add options Multiline.
精彩评论