Hello, I just have a small question - how can I cut off the leading character of a string? For example, in my case, I have a list of telephone numbers with a 1 at the beginning... I need to say that if the string is 11 characters long, delete the first character. How can I do this? I am very new to RoR and the RDOC is kinda confusing... Thanks in advance, - Jeff Miller -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
if string.size == 11 string=string[1..11] end On Jan 22, 1:58 pm, Jeff Miller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > I just have a small question - how can I cut off the leading character > of a string? For example, in my case, I have a list of telephone numbers > with a 1 at the beginning... I need to say that if the string is 11 > characters long, delete the first character. How can I do this? I am > very new to RoR and the RDOC is kinda confusing... > > Thanks in advance, > - Jeff Miller > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
or even better... string=string[1..11] if string.size==11 On Jan 22, 2:13 pm, jonbaty <jonb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> if string.size == 11 > string=string[1..11] > end > > On Jan 22, 1:58 pm, Jeff Miller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > Hello, > > I just have a small question - how can I cut off the leading character > > of a string? For example, in my case, I have a list of telephone numbers > > with a 1 at the beginning... I need to say that if the string is 11 > > characters long, delete the first character. How can I do this? I am > > very new to RoR and the RDOC is kinda confusing... > > > Thanks in advance, > > - Jeff Miller > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
http://www.noobkit.com/show/ruby/ruby/ruby-core/string This is where i get all my string info... great site... On Jan 22, 2:18 pm, jonbaty <jonb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> or even better... > > string=string[1..11] if string.size==11 > > On Jan 22, 2:13 pm, jonbaty <jonb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > if string.size == 11 > > string=string[1..11] > > end > > > On Jan 22, 1:58 pm, Jeff Miller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > > > > Hello, > > > I just have a small question - how can I cut off the leading character > > > of a string? For example, in my case, I have a list of telephone numbers > > > with a 1 at the beginning... I need to say that if the string is 11 > > > characters long, delete the first character. How can I do this? I am > > > very new to RoR and the RDOC is kinda confusing... > > > > Thanks in advance, > > > - Jeff Miller > > > -- > > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks everyone! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---