我需要url()从CSS文件中获取所有URL(表达式).例如:
b { background: url(img0) }
b { background: url("img1") }
b { background: url('img2') }
b { background: url( img3 ) }
b { background: url( "img4" ) }
b { background: url( 'img5' ) }
b { background: url (img6) }
b { background: url ("img7") }
b { background: url ('img8') }
{ background: url('noimg0) }
{ background: url(noimg1') }
/*b { background: url(noimg2) }*/
b { color: url(noimg3) }
b { content: 'url(noimg4)' } …Run Code Online (Sandbox Code Playgroud) 我想在php中编写正则表达式,以匹配双引号和单引号中的行.其实我正在编写用于删除css文件中的注释行的代码.
喜欢:
"/* I don't want to remove this line */"
Run Code Online (Sandbox Code Playgroud)
但
/* I want to remove this line */
Run Code Online (Sandbox Code Playgroud)
例如:
- valid code /* comment */ next valid code "/* not a comment */" /* this is comment */
Run Code Online (Sandbox Code Playgroud)
预期结果:
- valid code next valid code "/* not a comment */"
Run Code Online (Sandbox Code Playgroud)
请任何人根据我的要求在PHP中给我一个正则表达式.