From: Florian Gross Date: 2004-07-10T19:32:29+09:00 Subject: Re: Anomoly using pattern to remove superfluous final \, if present Moin! Richard Lionheart wrote: >>In your case I'd prefer >>s.sub!( /\\\\\z/, '\\' ) > I assume "z" is a typo for "$" and I further assume that using pattern > matching is much less efficient than directly "chopping" (though the > difference is imperceptible for the amount of data usually processed by > scripting languages.) \z is the very end of a String. It will always match after the last character of a String. $ is the end of a line. It will match before any \n character. There's also \Z which is the end of a String. It will match if you are at the end of the String or before a \n that is at the end of a String. Regards, Florian Gross