What regex to match all occurrences of css urls?

后端 未结 6 2156
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-20 14:36

i have a css file with a bunch of background image urls:

.alert-01 {
  background: url(\'img/alert-01.jpg\') center no-repeat;
}
.alert-02 {
  background: url(\'         


        
6条回答
  •  时光取名叫无心
    2021-02-20 15:00

    I came to this question from google. Old one, but none of the answer is discussing about data:image/* urls. Here is what I found on another google result that will only match http or relative urls.

    /url\((?!['"]?(?:data):)['"]?([^'"\)]*)['"]?\)/g
    

    I hope this would help other people coming from search engines.

提交回复
热议问题