Strings - trying to trim values


#1

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


#2

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


Several ways:

irb> myval = ‘wererwerwerwerweritop123233434345556#personID’
=> “wererwerwerwerweritop123233434345556#personID”
irb> myval[37…-1]
=> “personID”
irb> myval.split(’#’,2).last
=> “personID”
irb> myval[/[^#]*\z/]
=> “personID”

Take your pick!

-Rob

Rob B. http://agileconsultingllc.com
removed_email_address@domain.invalid


#3

Thanks Rob!