In a program I worked on, I wanted to replace all single-quotes
with a backslash+single_quote.  The following simple program:

  somestr = "'This isn't right.'"
  printf " Orig A:  %s\n", somestr
  printf " Test A1: %s\n", somestr.gsub(/'/, "\\'")
  printf " Test A2: %s\n", somestr.gsub(/'/, "\\=")
  printf " Test A3: %s\n", somestr.gsub(/'/) { |s| "\\'"}
  printf "\n"
  somestr = "=This isn=t right.="
  printf " Orig B:  %s\n", somestr
  printf " Test B1: %s\n", somestr.gsub(/=/, "\\'")
  printf " Test B2: %s\n", somestr.gsub(/=/, "\\=")
  printf " Test B3: %s\n", somestr.gsub(/=/) { |s| "\\="}
  exit 0

Prints out:

 Orig A:  'This isn't right.'
 Test A1: This isn't right.'This isnt right.'t right.
 Test A2: \=This isn\=t right.\=
 Test A3: \'This isn\'t right.\'

 Orig B:  =This isn=t right.=
 Test B1: This isn=t right.=This isnt right.=t right.
 Test B2: \=This isn\=t right.\=
 Test B3: \=This isn\=t right.\=

The output from TestA1 and TestB1 seem a bit odd to me...
I am running:  ruby 1.8.2 (2004-07-29) [i386-freebsd5]
-- 
Garance Alistair Drosehn     =             drosihn / gmail.com
Senior Systems Programmer               or   gad / FreeBSD.org
Rensselaer Polytechnic Institute;             Troy, NY;  USA