开发者

Regex to replace path

I have the below css

div style="background: transparent url('http://test.com/assets/admin/R7AcNoiUzbrr89.png') no-repeat"></div>

div style="backgroun开发者_Go百科d: transparent url(http://another.com/assets/admin/R7AcNeer89.png) no-repeat"></div>

How can I get rid of the hostname with a regex?

Thanks


You can try to replace that :

style="(.*)(http://([^/])*)(.*)"

by that :

style="$1$4"


Ruby:

str.gsub(/http:\/\/[^\/]+([^\)])/i, '/')

Js:

str.replace(/http:\/\/[^\/]+([^\)])/i, '/')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜