Ok, I’m hoping this won’t be a forehead slapper, but take a look at this
code:
physician.name.sub(/’/, “\’”)
I’m trying to substitute a single quote with a backslash and a single
quote. This seems pretty simple right? Well, someone kick me and
tell me why it’s not
Here’s what I’m getting if the physician’s name is Test’s User:
Tests Users User
Huh? Is this normal Ruby behavior (meaning I shoulda sent this to the
Ruby group) or is it something funky with the View code? (which is why
I sent this here first)
Thanks,
Brent J. wrote:
Ok, I’m hoping this won’t be a forehead slapper, but take a look at this
code:
physician.name.sub(/‘/, "\’")
I’m trying to substitute a single quote with a backslash and a single
quote. This seems pretty simple right? Well, someone kick me and
tell me why it’s not
Here’s what I’m getting if the physician’s name is Test’s User:
Tests Users User
Huh? Is this normal Ruby behavior (meaning I shoulda sent this to the
Ruby group) or is it something funky with the View code? (which is why
I sent this here first)
Thanks,
you neeed to replace it with “\\'”
have a look here:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/101824
and in the documentation for sub
–
Agnieszka
Ahhh, I should have thought to search for “backreference” instead of
just backslash. I did look at the API reference for the String object
but it didn’t mention the quadruple backslash.
Thanks for the info!