I am trying to write a regex that matches a comment that begins with a (*
and ends at the first occurence of a *)
(* comment *)
From other posts on stack overflow about matching between parenthesis I put together the following regex.
\(\*(([^*\)])*)\*\)
This works as long as there are no *
or )
characters within the comment. However, I want to allow these characters in a comment as long as they are not next to each other.
The following are all valid comments.
(*****)
(*()*)
(*)(*()**)
And a notable invalid comment is
(*)
I tried some stuff using lookaheads but to no avail. A pointer in the right direction would be appreciated.