我在 google 和 stackoverflow 上搜索过,但没有找到好的答案。我自己也尝试过,但我不是正则表达式大师。
我的目标是用绝对版本替换 html 样式标签中的所有相对 url。
例如
style="url(/test.png)"
和style="url(http://mysite.com/test.png)"
style="url("/test.png")"
和style="url("http://mysite.com/test.png")"
style="url('/test.png')"
和style="url('http://mysite.com/test.png')"
style="url(../test.png)"
和style="url(http://mysite.com/test.png)"
style="url("../test.png")"
和style="url('http://mysite.com/test.png')"
style="url('../test.png')"
和style="url('http://mysite.com/test.png')"
等等。
这是我用我可怜的正则表达式“技能”尝试的
url\((?<Url>[^\)]*)\)
给我“url”函数中的url。
提前致谢!