In trying to parse a C source file I have the following section of code: ... ... case line when /^.*\/\*.*?\*\/.*$/ # single line comment(s) non_comments = line.split(/\/\*.*?\*\//).to_s process_code(non_comments) when /^.*\/\*\*?[^(\*\/)]*$/ # multi-line start comment = true next when /^[^(\/\*)]*\*\/.*$/ # multi-line end comment = false ... ... I am running into a problem with the multi-line comment sections. While something like: /* A comment */ will work (i.e. gets properly parsed out) /* A * comment */ OR /* A * * comment */ will not. My guess is that it is because of the [^(\*\/)] construct blocking the leading or trailing '*' character. However, I thought that by placing the \*\/ within parenthesis I avoided the characters being evaluated individually. Is there a way to look for the pattern '*/' without having a single '*' break the search? As an alternative, I use this: when /^.*\/\*\*?[^(\*\/)]*\**?$/ comment = true next when /^.*?[^(\/\*)]*\*\/.*$/ comment = false Which *seems* to solve the problem, but I can see where it is brittle /* A * comment for * instance */ Any suggestions? Thanks in advance.