From: George Ogata Date: 2002-07-24T00:26:35+09:00 Subject: Re: Strings and member-operators Hello, David Alan Black wrote: > Hi -- > > On Tue, 23 Jul 2002, Dossy wrote: > >> On 2002.07.23, David Alan Black wrote: >> > class String >> > def stripQuotes >> > /^("?)(.*?)(\1)$/.match(self)[2].strip >> > end >> > end >> >> Very cool. I wonder why you had to wrap \1 in parens, though. >> Just for visual symmetry, or did it only work that way? > > Good question. I think it was left over from some intermediate > version that used the grouping for something. It can definitely go. > > > David > Is there an advantage to using .*? there instead of .*? (That second '?' there is punctuation, not part of the regex). Or would there be no difference at all, assuming there were no newlines in the matched string? Speaking of which, isn't it an idea to turn on the mutliline flag? Or use \A...\z? You could butcher something like: "Some quote" --- Some guy. (I'm not very good with quotes ;))