I have a string for e.g.
String src = \"How are things today /* this is comment *\\*/ and is your code /*\\* this is another comment */ working?\"
>
Try this one:
(//[^\n]*$|/(?!\\)\*[\s\S]*?\*(?!\\)/)
If you want to exclude the parts enclused in " " then use:
(\"[^\"]*\"(?!\\))|(//[^\n]*$|/(?!\\)\*[\s\S]*?\*(?!\\)/)
the first capturing group identifies all " " parts and second capturing group gives you comments (both single line and multi line)
copy the regular expression to regex101 if you want explanation