Hai I am trying one small pattern . but it giviong lot of problem. For example I am getting string like "Hai I an fine 11111 22222 2222 33333" from this i want only integer part.like this ''11111 22222 2222 33333'' i am using str=~/\s\d+$/, But i am getting only first part like ''1111''. i want all the digit part. regards Selvaraj -- 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 -~----------~----~----~----~------~----~------~--~---
You probably want a character class: /[\s\d]+$/ ... to check for any number of spaces or digits in a row. I didn''t test this (and I don''t use regex often) but hopefully this points you in the right direction. -- Wes On Mar 21, 9:27 am, selvaraj <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hai > > I am trying one small pattern . but it giviong lot of problem. > > For example I am getting string like "Hai I an fine 11111 22222 2222 > 33333" > > from this i want only integer part.like this ''11111 22222 2222 33333'' > > i am using str=~/\s\d+$/, But i am getting only first part like ''1111''. > i want all the digit part. > > regards > Selvaraj > > -- > 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 -~----------~----~----~----~------~----~------~--~---
ya very many thanks.. its working fine wesgarrison wrote:> You probably want a character class: > /[\s\d]+$/ > > ... to check for any number of spaces or digits in a row. > > I didn''t test this (and I don''t use regex often) but hopefully this > points you in the right direction. > > -- Wes-- 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 -~----------~----~----~----~------~----~------~--~---
On Wed, 21 Mar 2007 15:27:50 +0100 selvaraj <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hai > > I am trying one small pattern . but it giviong lot of problem. > > For example I am getting string like "Hai I an fine 11111 22222 2222 > 33333" > > from this i want only integer part.like this ''11111 22222 2222 33333'' > > i am using str=~/\s\d+$/, But i am getting only first part like > ''1111''. i want all the digit part. > > regards > SelvarajFor that to work, you need to do some grouping with () in your regexp. /(\s\d)+/ will get you any sequence of digits and spaces. /(\s\d+)+/ will get you any number of sequences of a space followed by any number of digits. -- Jamie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---