Substituting apostrphe's

It took four backslashes to get it to work.

a.sub(/‘/, "\\’") # => “don\'t”

I’m embarassed to say how long it took me to figure that out.

This works for you? I get a different answer… (NOT in irb, mind
you)

c:\tmp>ruby -v
ruby 1.8.0 (2003-08-04) [i386-mswin32]

c:\tmp>cat tmp.rb
a = “don’t”
puts a.gsub(/'/, “\'”)

Hmmm … I count three backslashes instead of four. I get the same result
as you with three.

Four backslashes works for me in both irb and ruby scripts (tried both 1.6
and 1.8).

···

From: Michael Campbell [mailto:michael_s_campbell@yahoo.com]


– Jim Weirich / Compuware
– FWP Capture Services
– Phone: 859-386-8855