Reputation: 107
Why am I getting a stackOverFlowError when running a regex to search a commented string?
regex:
/\*(?!\*)(?:.|\W)*?\*/
It's not giving an error when I search in a particular Java file, but it does when I search it over the whole project.
Upvotes: 1
Views: 437
Reputation: 174706
I suggest you to change your regex like this,
\/\*(?!\*)[\s\S]*?\*\/
[\S\s]*?
will match any space or non-space charcaters non-greedily. Thus it would match also the line-breaks.
Upvotes: 1