From: Robert Date: 2003-04-28T15:39:58+09:00 Subject: Re: Regexp and $ Did you look at \z, \Z and option "m" (multiline mode)? robert "Brian Candler" schrieb im Newsbeitrag news:20030427121720.GA38491@uk.tiscali.com... > 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 }' abc > z > > So it seems to me this is an anomoly introduced by Ruby. > > Regards, > > Brian. >