Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Strings - trying to trim values
Mmcolli00 Mom
1/22/2009 8:10:00 PM
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-...
.
2 Answers
Rob Biedenharn
1/22/2009 8:22:00 PM
0
On Jan 22, 2009, at 3:09 PM, Mmcolli00 Mom wrote:
> 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:
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 Biedenharn
http://agileconsult...
Rob@AgileConsultingLLC.com
Mmcolli00 Mom
1/23/2009 3:00:00 AM
0
Thanks Rob!
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Strings - trying to trim values
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password