I have a css file with a set of background image urls:
.alert-01 { background: url('img/alert-01.jpg') center no-repeat; } .alert-02 { background: url('img/alert-02.jpg') center no-repeat; } .alert-03 { background: url('img/alert-03.jpg') center no-repeat; } .alert-04 { background: url('img/alert-04.jpg') center no-repeat; }
And I would like to write a regex that strips the URL.
So, initially I would get:
url('img/alert-01.jpg') url('img/alert-02.jpg') url('img/alert-03.jpg') url('img/alert-04.jpg')
Why could I replace the bits to turn them into html <img> .
I'm fine with the last bit, but my regex skills are a little rusty.
My last attempt: /^url\(.*?g\)$/ig
Any help?
By the way, I did all this in javascript, but the language should not affect the regular expression.
Thanks in advance!
Also, just to mention, I cannot guarantee that the files will always be jpg and can be jpeg, png, etc. Also, that the arguments in the background will always be the same. Therefore, why I want to extract only part of the url.
javascript css regex
Ryk waters
source share