> Suppose a line > > MopqMopc > > ^.*M match the line from beginning to the second M, but I want to match > the beginning to the first M, how can I do it?
There are a number of ways to do it that you can riff off of depending on the scenario: ^\s*M ^.{-}M ^.*\<M ^[^M]*M I'm sure there are several others I've missed. :) -tim