--p2pkNiL1PnZBJ6Nr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Jul 22, 2011 at 12:05:54AM +0900, Gaurang Shah wrote:
> Hi all,
>=20
> I have string something like
> String path =3D  "C:\Gaurang\ruby\demo.xls"
>=20
> would someone let me know how to replace "\" with "\\"
>=20
> I tried something like below
>=20
> path.gsub("\\", "\\\\")

Are you _assigning_ the return value of the above call to another object
(or back to path)?

HINT: gsub doesn't alter the String but instead _returns_ one with the
altered value: but gsub! (not the !) alters the existing string.

--=20
Darryl L. Pierce <mcpierce / gmail.com>
http://mcpierce.multiply.com/
"What do you care what people think, Mr. Feynman?"

--p2pkNiL1PnZBJ6Nr
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk4oVP0ACgkQtddqM0QFuLLVXACeNSmRHspIrIXREjBUfme11/VO
zToAoMWGRPp9bMw9XV/uJu4I4+ZQqdhu
=diuw
-----END PGP SIGNATURE-----

--p2pkNiL1PnZBJ6Nr--

On Fri, Jul 22, 2011 at 12:05:54AM +0900, Gaurang Shah wrote:
> Hi all,
>=20
> I have string something like
> String path =3D  "C:\Gaurang\ruby\demo.xls"
>=20
> would someone let me know how to replace "\" with "\\"
>=20
> I tried something like below
>=20
> path.gsub("\\", "\\\\")

Are you _assigning_ the return value of the above call to another object
(or back to path)?

HINT: gsub doesn't alter the String but instead _returns_ one with the
altered value: but gsub! (not the !) alters the existing string.

--=20
Darryl L. Pierce <mcpierce / gmail.com>
http://mcpierce.multiply.com/
"What do you care what people think, Mr. Feynman?"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk4oVP0ACgkQtddqM0QFuLLVXACeNSmRHspIrIXREjBUfme11/VO
zToAoMWGRPp9bMw9XV/uJu4I4+ZQqdhu
=diuw
-----END PGP SIGNATURE-----