开发者

RegEx: Not contain specific file types

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜