注释的正则表达式是这样的:
/**
* -string- (possible line)
-possibly more lines like the above one-
*/
Run Code Online (Sandbox Code Playgroud)
例如:
/**
* The Boring class implements this and that
* and also...
* does this and that
*/
Run Code Online (Sandbox Code Playgroud)
一个简单/\*\*.*?\*/的dotall(点匹配所有)标志应该可以做到这一点.虽然它可能需要不同的转义或可能的分隔符,具体取决于您正在使用的正则表达式引擎的风格.
如果您的引擎中没有dotall,请尝试以下方法:
/\*\*[\s\S]*?\*/
Run Code Online (Sandbox Code Playgroud)