From: ara.t.howard@... Date: 2006-10-27T02:38:43+09:00 Subject: Re: Question about strings On Fri, 27 Oct 2006, William Carpin wrote: > Okay, given the following string: > > "This is Will's string!" > > what I'm trying to do is replace the single-tick "'" character with a > backslash/single-tick "\'", so I can use use that string in a sql query. > > To do this in Perl, you'd do the following: > > myString =~ s/\'//g; > > ...which doesn't work in Ruby. > > I also tried using the gsub function, with "\\\'" passed in as the > second parameter, and it just started outputting some sort sort of > goofiness with characters replaced by sub-elements of the string for > which I was calling the function on and the like. > > I scoured Google for awhile but didn't find anything. Any ideas? irb(main):001:0> "This is Will's string!".gsub(/'/){ %q(\') } => "This is Will\\'s string!" -a -- my religion is very simple. my religion is kindness. -- the dalai lama