Paul Lutus wrote: > Also, I don't immediately see a difference in > behavior between \z and $, contrary to the documentation's specification > that one matches the end of a line and the other matches the entire string. The \z matches up to the terminus of the entire string, including any newlines that come between. It's different from $ with multiline because that will match every line end. To see it, change your example to a << s.sub(/(^.*$)/,'REPLACE') a << s.sub(/(^.*\z)/,'REPLACE') a << s.sub(/(^.*$)/m,'REPLACE') a << s.sub(/(^.*\z)/m,'REPLACE') Regards, Jordan