From: Tom Sawyer Date: 2002-07-24T01:13:38+09:00 Subject: Re: Strings and member-operators let me get this straight? is the original question how to strip a string and remove quotes? /^("?)(.*)\1$/.match(self)[2].strip this only does double quotes and its striping after the quotes removal. is that what's wanted? well, i'll assume so. what about without regexp? return str[1..-1].strip if str[0..0] + str[-1..-1] == '""' hmmm... you'd think there'd be a real simple way to do this without regexp, can it get any simpler? ~transami On Tue, 2002-07-23 at 09:38, David Alan Black wrote: > Hi -- > > On Wed, 24 Jul 2002, George Ogata wrote: > > > 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 > > > > 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. > > Hmmmm... Like the other thing Dossy pointed out (putting () around > \1), I think the ? was left over from some intermediate version where > it mattered. > > OK, so now we're looking at: > > /^("?)(.*)\1$/.match(self)[2].strip > > > I hadn't addressed the whole multi-line issue -- it wasn't in Dossy's > test suite :-) > > > David > > -- > David Alan Black > home: dblack@candle.superlink.net > work: blackdav@shu.edu > Web: http://pirate.shu.edu/~blackdav > > -- ~transami