identify a comment between /* and */ that may contain */ inside of it only if its inside “”

  Kiến thức lập trình

I am working on a lexical analyser but i am struggling on how to identify the comments as bellow:
a comment is a sequence of caracters (even space) between /* and /*, it may not contain the sub-string / unless it is between doubles quotes like this “/”

i only could do this two attempts:
pattern commentPattern = Pattern.compile(“/.?/”); // it identify the comment between /* and */

and this attempt:
pattern commentPattern = Pattern.compile(“/.? “/ .? */”);

Can you please help ?

New contributor

Anastasia Frontend is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT