我正在尝试使用JavaScript正则表达式来捕获CSS多行注释块,但是我不确定如何找到闭合注释标记,而避免在HTML示例中得到偶尔出现的斜杠,以下是一个具体案例:
/*@comment
@title: Buttons
@name: block-name
@category: Category name > Sub category
@description: This is the description of the element
@html:
<div class="block-name"></div>
*/
我正在尝试使用这个正则表达式,但是我只能匹配到闭合的div标签:
\/\*@comment([^\*\/]){1,}
所以我尝试添加结束注释标记,但它停止工作了:
\/\*@comment([^\*\/]){1,}\*\/
如何找到一个JavaScript正则表达式来捕获整个块?
请注意,我可以在每个文件中找到多个这样的块,因此我将在正则表达式上使用g
标记。
\/\*[\s\S]*?\*\/
。 - Wiktor Stribiżew'a/*b*/c/*d*/'.match(/\/\*([^;]*)\*\//g)
的输出结果是["/*b*/c/*d*/"]
而不是["/*b*/", "/*d*/"]
。 - Oriol