Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在phpstorm中使用regex使用replace工具删除php注释_Php_Regex_Comments_Phpstorm - Fatal编程技术网

在phpstorm中使用regex使用replace工具删除php注释

在phpstorm中使用regex使用replace工具删除php注释,php,regex,comments,phpstorm,Php,Regex,Comments,Phpstorm,如何使用正则表达式从php文件中删除多行注释?我尝试了“/\*(.*\n)*\*/”但失败了。它所做的一切都是以“/*”开头,并在最后一次出现“*/”时停止 所有php注释的最终解决方案如下所示: /\*[\s\s]*?\*/|( 在哪里 1) /\*[\s\s]*?\*/用于/*注释*/ 2) (?对于单行//comment转义URL,以http:// (最好不要显示前面有“或”的内容,但我现在还可以) 哦,还有tenub,如果你发布了一个正确的答案而不是评论,我会接受的。因为你帮助了ty)/

如何使用正则表达式从php文件中删除多行注释?我尝试了“/\*(.*\n)*\*/”但失败了。它所做的一切都是以“/*”开头,并在最后一次出现“*/”时停止

所有php注释的最终解决方案如下所示:

/\*[\s\s]*?\*/|(

在哪里

1)
/\*[\s\s]*?\*/
用于
/*注释*/

2)
(?对于单行
//comment
转义URL,以
http://
(最好不要显示前面有
的内容,但我现在还可以)


哦,还有tenub,如果你发布了一个正确的答案而不是评论,我会接受的。因为你帮助了ty)

/\*(.+?)\*/s
Regex可能无法处理所有的边缘情况。另外,如果评论是在单行上,请参阅。/\*(.+?)\*/如果评论是在单行上,更通用的Regex应该是
/\*[\s\s]*?\*/\*/././/.
,因为
[\s\s]
将能够匹配每个字符。谢谢Jerry。我真的应该找个时间学习正则表达式。它非常有用。
[\s\s]
的+1,这似乎是PhpStorm中匹配所有
的唯一解决方案,包括新行字符(搜索很长时间才能找到)。