FCC wrote:
Initially I was trying to use isearch for a regexp but only to
search for those occurences which are not in comments (or which do
not appear after the character !). After spending some time with
Google, it turned out that this is not possible because one cannot
"invert a match", which is what is required here.
M-x occur ^[^!C-qC-j]*regexp
ought to work (the C-qC-j bit gives you a newline).
It will be fooled by instances of your desired regexp occurring after
a string containing !, but I imagine that's unlikely. If you needed
to deal with that, you could cook up some elisp using f90-in-comment.