Luke wrote:
(Solved! See below for details.)
I've just figured it out. The difference between the greps and PCRE, is that in the greps, the data is taken on a line by line basis. So, ^ matches the start of a line. PCRE is not treating newline specially, so ^ and $ apply to the beginning and end of the entire pattern space.
You could fiddle about with the options:
# m Multiline mode - ^ and $ match internal lines # s match as a Single line - . matches \n
c.f. perlreref
Dick