A snippet of code I found on my hard-drive that might be useful, thus, I want to document here.
It’s a simple Reg-exp to extract the full URL from a CSS background-image
url property:
// you have
var csspath = 'url(myImage.png)'
// and want to get 'myImage.png'
var reg = new RegExp(/url\((.*)\)/gim)
var cleanPath = reg.exec(csspath)
if(cleanPath) console.log(cleanPath[1])
Have fun!
Update: A better reg-ex in this post.
Spotted a typo or (likely) a grammar error? Send a pull request.