Strings - trying to trim values

What is the correct way to trim off the the first 37 characters of a
string?

I want to trim off the value from position 0 -> pos 37 or take off all
characters from right side and stopping at a specific character #.

myval = wererwerwerwerweritop123233434345556#personID

How is this done? Thanks.
MC

···

--
Posted via http://www.ruby-forum.com/.

What is the correct way to trim off the the first 37 characters of a
string?

I want to trim off the value from position 0 -> pos 37 or take off all
characters from right side and stopping at a specific character #.

myval = wererwerwerwerweritop123233434345556#personID

How is this done? Thanks.
MC
--

Several ways:

myval = 'wererwerwerwerweritop123233434345556#personID'

=> "wererwerwerwerweritop123233434345556#personID"

myval[37..-1]

=> "personID"

myval.split('#',2).last

=> "personID"

myval[/[^#]*\z/]

=> "personID"

Take your pick!

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com

···

On Jan 22, 2009, at 3:09 PM, Mmcolli00 Mom wrote:

Thanks Rob!

···

--
Posted via http://www.ruby-forum.com/.