开发者

Regex to remove hostname from image

I want to 开发者_开发知识库remove the hostname from all the background css declarations I have in a html page

ie

<div style="background:transparent url(http://www.some-domain.com/images/test.png) no-repeat"></div>

to become

<div style="background:transparent url(images/test.png) no-repeat"></div>

Any ideas guys?

Thanks


replace the regex "http://[^/]*" with "/".


http://(.*?)images

If you do a regex replace, you can then remove the match and you should be ok.


try

(http:\/\/\w.*\/)

and replace the matched pattern with /

DEMO

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜