开发者

RegEx: Not contain specific file types

开发者 https://www.devze.com 2023-02-20 03:11 出处:网络
I\'m searching for a regular expression that hits everything that is NOT ending with \".png\" or \".jpg\". I want to find out URLs that开发者_如何学Python do not request an image file.

I'm searching for a regular expression that hits everything that is NOT ending with ".png" or ".jpg". I want to find out URLs that开发者_如何学Python do not request an image file.

I found something like this: ([^\s]+(\.(?i)(jpg|png))$) but this is pretty much the opposite of what I want.

Is there an easy way to reverse this? Or is this expression totally wrong?!

Thanx in advance. Jan


This can be done using negative lookahead:

([^\s]+(\.(?i)(?!jpg$|png$)[^\s]+)$)

That expression will match file.gif and file.png2 but not file.png.

See also: Regex help. Lighttpd rewrite rule

0

精彩评论

暂无评论...
验证码 换一张
取 消