【发布时间】:2010-10-21 04:51:02
【问题描述】:
我想在 php 中编写正则表达式来匹配双引号和单引号内的行。实际上我正在编写用于删除 css 文件中的注释行的代码。
喜欢:
"/* I don't want to remove this line */"
但是
/* I want to remove this line */
例如:
- valid code /* comment */ next valid code "/* not a comment */" /* this is comment */
预期结果:
- valid code next valid code "/* not a comment */"
请任何人给我一个 php 中的正则表达式以满足我的要求。
【问题讨论】:
-
您可能只是想使用现有的压缩器而不是自己解析 CSS,除非您有一些非常具体的理由这样做。见CSS - How to remove comments and make CSS one line。另外:Don't Do It.