Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.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
C# 代码镜像仅获取取消注释代码_C#_Javascript_Codemirror_Jshint - Fatal编程技术网

C# 代码镜像仅获取取消注释代码

C# 代码镜像仅获取取消注释代码,c#,javascript,codemirror,jshint,C#,Javascript,Codemirror,Jshint,我已经在我们的asp.net应用程序中实现了最新的代码镜像。编辑器允许键入包含注释代码和未注释代码的javascript 我想知道编辑器中编写的所有代码是否都已注释 任何人都可以提供建议。您可以获取文档文本,然后通过: var editor=CodeMirror.fromTextArea(document.getElementById('code'){ 行号:对 }); var out=document.getElementById('out'); out.textContent=editor.

我已经在我们的asp.net应用程序中实现了最新的代码镜像。编辑器允许键入包含注释代码和未注释代码的javascript

我想知道编辑器中编写的所有代码是否都已注释


任何人都可以提供建议。

您可以获取文档文本,然后通过:

var editor=CodeMirror.fromTextArea(document.getElementById('code'){
行号:对
});
var out=document.getElementById('out');
out.textContent=editor.getValue()
.replace(/(?:\/\*(?:[\s]*?)\*\/)|(?:[\s;]+\/\/(?:.*))/gm',);


或者是否有任何方法可以从javascript字符串中找到代码是否对代码进行了注释。我想我也找到了同样的解决方案<代码>(\/\/.\/\*[\s\s]*?\*\/)将有助于查找单行和多行注释。删除匹配的正则表达式并检查javascript字符串的长度。如果长度更大,则有一些有效代码,或者如果长度为零,则代码为死代码。哦,我刚刚在发布答案后看到你的评论。。。很高兴你把它整理好了,我希望我的解决方案会有所帮助。