I want to match multiline comments that contain a specific word, let's say findthis
. The first pattern that comes to mind is \/\*.*?findthis.*?\*\/
(using DOTALL
). The problem with this pattern however is that a string like this:
/* this is a comment */
this is some text
/* this is a findthis comment */
will match the whole text. Basically, on a bigger file, the first match would contain everything from the first comment to the first comment containing findthis
. How can I prevent this?