From: Brian Candler Date: 2003-04-27T21:17:23+09:00 Subject: Re: Regexp and $ On Sun, Apr 27, 2003 at 09:05:29PM +0900, ts wrote: > B> I think this difference in behaviour is unfortunate, as I consider that "^" > B> and "$" are part of the lowest-common-denominator of regexp behaviour which > B> ought to be reasonably portable. > > Why use the broken P implementation ? I guess I am used to: s/[\r\n\s]+$//; # Strip trailing spaces and newlines Somehow it seems right to me that $ matches "end of string", perhaps because a long time ago I did a course which had a more formal definition of regular expressions, and $ was used to mean end of input stream. FWIW, awk agrees with Perl: $ awk -- 'BEGIN { a="abc\n"; gsub("$","z",a); print a }'