How to find below comment block(s) with javascript/jquery regex:
/*
some description here
*/
It may even look like:
/* some description here
*/
Or
/* some description here */
With php I think it would be :
$pattern='/\/\*.*?/*///';
or
$pattern='/\*[^*]*\*+([^/*][^*]*\*+)*/';
chk this out
Improving/Fixing a Regex for C style block comments
This is to match empty comment blocks :
^\s+/\*{1,}\n(^\s*\*{1,}\s*)+\*{1,}/
Here's an actual Javascript answer:
var commentRegex = /\/\*([^/]|\/[^*])*\*\//;
If you need a version that checks to see whether an entire string is a comment:
var completeCommentRegex = /^\/\*([^/]|\/[^*])*\*\/$/m;
Explanation: the regex matches a leading /*, followed by any number of either individual characters other than "/", or "/" followed by anything not an asterisk, and then finally the closing */. The "m" flag in the second version ensures that embedded newlines won't mess up the "^" and "$" anchors.
Finally, if you actually want the comment text, you'd add an appropriate parenthesized block in there (after the /* and before the */).
var match = myString.match(/\/\*([\w\W]*)\*\//)
If match !== null, match[0] will contain the comment, and match[1] will contain the comment without the comment delimiters.
edit: it's multiline now ;)
[d\D] instead of .. That will match newlines. At least it does so in .NET =). doesn't match \n but \W does. Worse, it looks like you can't match . with anything else in a []. So [.\n] is not valid.