I have a Javascript file like that
/**
* My Comment Line1
* My Comment Line2
*/
var a = 123;
/**
* My Comment Line3
* My Comment Line4
*/
var b = 456;
I am using node.js to read the file and want to extract comments in this file.
I use this regexp
/\/\*\*((?:\r|\n|.)*)\*\//
However this extracts
/**
* My Comment Line1
* My Comment Line2
*/
var a = 123;
/**
* My Comment Line3
* My Comment Line4
*/
My program have a loop to extract matched block one by one. So I want a RegExp to extract
First loop
/**
* My Comment Line1
* My Comment Line2
*/
Second loop
/**
* My Comment Line3
* My Comment Line4
*/
The rule is simply that comment block starts with /**
and ends with */
. Inside a comment, all characters are allowed.
Could anyone help me? Thanks!