Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3389

Re: String problem

From "WJ" <w_a_x_man@yahoo.com>
Newsgroups comp.lang.ruby
Subject Re: String problem
Date 2011-04-22 19:38 +0000
Organization NewsGuy - Unlimited Usenet $19.95
Message-ID <ioslfn01to3@enews5.newsguy.com> (permalink)
References <b6b1c8892065126a3980ffcb280fcd37@ruby-forum.com>

Show all headers | View raw


Cyril Jose wrote:

> Hello all,
> 
> 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:
> 
> str = ">Hello World\n"
> new_var = " Hello World"
> 
> Any ideas to point me in the right direction?

">Hello World\n"[ /.(.*)/, 1]
    ==>"Hello World"
">Hello World\n".rstrip[ 1 .. -1]
    ==>"Hello World"

Back to comp.lang.ruby | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

String problem Cyril Jose <cyril_jose@ymail.com> - 2011-04-20 11:48 -0500
  Re: String problem Hans Mackowiak <hanmac@gmx.de> - 2011-04-20 11:52 -0500
    Re: String problem Cyril Jose <cyril_jose@ymail.com> - 2011-04-20 11:54 -0500
      Re: String problem Robert Klemme <shortcutter@googlemail.com> - 2011-04-23 00:04 +0200
  Re: String problem Cyril Jose <cyril_jose@ymail.com> - 2011-04-21 20:36 -0500
  Re: String problem "WJ" <w_a_x_man@yahoo.com> - 2011-04-22 19:38 +0000

csiph-web