I am trying to write a regular expression which finds all the comments in text.
For example all between /* */
.
Example:
/* Hello */
Just an additionnal note about using regex to remove comments inside a programming language file.
Warning!
Doing this you must not forget the case where you have the string /*
or */
inside a string in the code - like var string = "/*";
- (we never know if you parse a huge code that is not yours)!
So the best is to parse the document with a programming language and have a boolean to save the state of an open string (and ignore any match inside open string).
Again a string delimited by "
can contain a \"
so pay attention with the regex!