正则表达式阅读代码评论(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] *[*]+\/更多推荐
发布评论