getting end of string

S

Simon Krahnke

Hi,

I have a string s and I'm only interested in everything in it after the
first character.

So at the moment I do

| s[1,128].bytes

Just putting 128 as the length cause that's probably bigger than
anything I'll ever enter into my tool. But there's gotta be a better way
of doing that except going to Regexps.

mfg, simon .... confused
 
D

Doc O'Leary

Simon Krahnke said:
I have a string s and I'm only interested in everything in it after the
first character.

So at the moment I do

| s[1,128].bytes

Just putting 128 as the length cause that's probably bigger than
anything I'll ever enter into my tool. But there's gotta be a better way
of doing that except going to Regexps.

Depending on your needs, these spring to mind:
here = "this is a string for you" => "this is a string for you"
here[1,here.length] => "his is a string for you"
here[1..-1] => "his is a string for you"
here[0] = "" => ""
here
=> "his is a string for you"
 
S

Simon Krahnke

* Doc O'Leary said:
Simon Krahnke said:
I have a string s and I'm only interested in everything in it after the
first character.

So at the moment I do

| s[1,128].bytes

Just putting 128 as the length cause that's probably bigger than
anything I'll ever enter into my tool. But there's gotta be a better way
of doing that except going to Regexps.

Depending on your needs, these spring to mind:
here = "this is a string for you" => "this is a string for you"
here[1,here.length] => "his is a string for you"
here[1..-1]

Thank you, I like this one. Didn't come to my mind, that the Range would
do it.
=> "his is a string for you"
here[0] = "" => ""
here
=> "his is a string for you"

It's the start of a chain of operations in one line. Likes this:

| when /^h/ then s[1..-1].scan(/../).map { | d | d.hex }

mfg, simon .... binshow.rb replaces binshow.pl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top