【发布时间】:2019-04-23 11:57:42
【问题描述】:
我想使用 Shell Script 或 AppleScript 从 PHP 文件的源代码中删除 cmets。 (我正在使用 Codekit OS X App 挂钩)
我尝试使用 sed 或 grep 命令执行此操作,但我习惯于使用 PHP / javascript 的现代正则表达式代码不起作用。
https://regex101.com/r/awpFe0/1/
演示足以告诉我我想做什么。
我需要命令行上的工作版本。
我找到了这个,但我无法得到我想要的结果: https://stackoverflow.com/a/13062682/6320082
我已经工作了两天了。请帮帮我。
示例内容:
Test string // test comment
Test string// test comment
echo 1;//test comment
http://domain.ltd // test comment
$wrong_slashes = "http://domain.ltd/asd//asd//asd";
function test() { // test comment
Test string /* test comment // test comment */
Test string //test /* test */
Test string /* test comment /* */ */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
/**
multi-line comments
*/
<script src="//cdn.com/site.js">
$pattern = "([//])";
$pattern = '([//])';
<!-- html comments -->
<div>test</div> <!-- html comments -->
<!-- html comments --> <div>test</div>
【问题讨论】:
标签: regex bash sed command-line grep