Title |
Test
Find
Pattern Title
|
Expression |
/\*[\d\D]*?\*/ |
Description |
If you need to extract or remove any /* */ sytle comments from any Java, JavaScript, C, C++, CSS, etc code you have this regular expression can help. |
Matches |
/* my comment */ | /* my multiline comment */ | /* my nested comment */ |
Non-Matches |
*/ anything here /* | anything between 2 seperate comments | \* *\ |
Author |
Rating:
Chris Craft
|
Source |
http://www.cjcraft.com/ |
Your Rating |
|
Title: afdaf
Name: afdasfd
Date: 1/9/2005 1:09:29 AM
Comment:
/* this is a comment*/
Title: matching comments correctly
Name: Trevor Miranda
Date: 10/28/2003 5:05:45 AM
Comment:
A correct solution that will handle comments inside quoted string is available in perlfaq6. Try this link: http://www.perldoc.com/perl5.6.1/pod/perlfaq6.html#How-do-I-use-a-regular-expression-to-strip-C-style-comments-from-a-file-
Title: Doesn't properly match nested comments
Name: Jan Willem
Date: 8/19/2003 10:44:48 AM
Comment:
/* outer comment */ inner comment */
This should not match since the amount of /* 's is lower than the amount of */ 's
Title: Problem with Strings
Name: Markus
Date: 5/21/2003 5:34:55 AM
Comment:
You will run into Problems, if you actually use this RE on a Code like this:
(JAVA)
text := " /* ";
Command;
/* COMMENT */
This RE will include everything starting from the first /*