The regex does not match multi-line comments because, the "." character class matches everything except line terminators - \n(unix line terminator),\r(carriage return),\u0085(next line),\u2028(line separator),\u2029(paragraph separator). So, the \n character wont be matched by default.
To make "." match all characters, you must use the other Pattern.compile() signature
DOTALL flag when set, will match "." with any character. This must solve your problem.
Or alternatively, the regex can be defined as
Here, in the first part of the regex, ".*" wont match \n character. So you wont need that "[^\\n]*" part.
In the second part, you can see we have used "(?s)". This is a regex flag and it implies that starting from the place where "(?s)" is encountered to the place "?(-s)", "." will match everything on its way. If we skip "(?-s)", it is equivalent to DOTALL flag for the entire remaining regex.
Beware, setting the flag in the Patter.compile() method call will apply it to the entire regex.
This kind of regex flag setting will come in handy, when you need to partially apply the DOTALL flag or CASE_INSENSITIVE flag..or any others.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com