正则表达式阅读代码评论(Regex to read code comment)

编程入门 行业动态 更新时间:2024-10-27 20:24:16
正则表达式阅读代码评论(Regex to read code comment)

我有像这样的代码注释块..

/** * This method provide inheritance to the object supplied; this method inherit the * public methods from the Parent class to the Child class. this also provide * multiple inheritance, in which the method ambiguity is solved by the overriding * the last inherited class's method. * @access public * @method inherit * @param Object Parent * @param Object Child * @return Object */

并忽略像这样的评论

/* This is a test comment for testing regex. */

我尝试了很多在javascript中使用正则表达式获得此评论并且每次都失败。 任何人都可以建议这个或任何其他解决方案提取注释块的正则表达式。

i have code comment block like this..

/** * This method provide inheritance to the object supplied; this method inherit the * public methods from the Parent class to the Child class. this also provide * multiple inheritance, in which the method ambiguity is solved by the overriding * the last inherited class's method. * @access public * @method inherit * @param Object Parent * @param Object Child * @return Object */

and ignore comments like

/* This is a test comment for testing regex. */

i tried a lot to get this comment using regex in javascript and failed every time. can anyone suggest a regex for this or any other solution to extract the comment block.

最满意答案

我假设你只是在寻找多行注释,这里有一个确实如此。

\/[*]+[\n\r][\s\S]+?[\n\r] *[*]+\/

I'm assuming you're looking for multiline comments only, here is one which does exactly that.

\/[*]+[\n\r][\s\S]+?[\n\r] *[*]+\/

更多推荐

本文发布于:2023-08-03 03:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1383133.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   正则表达式   Regex   comment   code

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!