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

On Thu, Apr 21, 2011 at 01:48:55AM +0900, Cyril Jose wrote:
>=20
> I am trying to read characters in a string but I want to ignore the
> first character and the newline at the end of the string, then store the
> characters in between into a new variable:
>=20
> str =3D ">Hello World\n"
> new_var =3D " Hello World"
>=20
> Any ideas to point me in the right direction?

There are probably a dozen ways to do that, but how you do it probably
depends on what, overall, you really want to accomplish.  Examples, with
slightly different results:

    str.slice!(0) && str.slice!(-1)=20

    new_var =3D str.gsub(/^./, ' ').chomp

The former gives you what you described, but not what you showed in your
example.  The latter gives you exactly what you what your example
suggests.  Do you actually want that space at the beginning of the new
string?

The short version of pointing you in the right direction is "I would
suggest reading about the methods in the String class."

    http://ruby-doc.org/core/classes/String.html

--=20
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]

--3MwIy2ne0vdjdPXF
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAk2vDSwACgkQ9mn/Pj01uKW1HQCg3WZnVZkuhEU9cdAIA8CJr+yu
67QAnRfWWr4mIdcNVna1A0565VXxATAw
=uoK7
-----END PGP SIGNATURE-----

--3MwIy2ne0vdjdPXF--

On Thu, Apr 21, 2011 at 01:48:55AM +0900, Cyril Jose wrote:
>=20
> I am trying to read characters in a string but I want to ignore the
> first character and the newline at the end of the string, then store the
> characters in between into a new variable:
>=20
> str =3D ">Hello World\n"
> new_var =3D " Hello World"
>=20
> Any ideas to point me in the right direction?

There are probably a dozen ways to do that, but how you do it probably
depends on what, overall, you really want to accomplish.  Examples, with
slightly different results:

    str.slice!(0) && str.slice!(-1)=20

    new_var =3D str.gsub(/^./, ' ').chomp

The former gives you what you described, but not what you showed in your
example.  The latter gives you exactly what you what your example
suggests.  Do you actually want that space at the beginning of the new
string?

The short version of pointing you in the right direction is "I would
suggest reading about the methods in the String class."

    http://ruby-doc.org/core/classes/String.html

--=20
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAk2vDSwACgkQ9mn/Pj01uKW1HQCg3WZnVZkuhEU9cdAIA8CJr+yu
67QAnRfWWr4mIdcNVna1A0565VXxATAw
=uoK7
-----END PGP SIGNATURE-----