I have a string composed of three parts. 1) a number, could be 1, 2, 3, 4 or more digits. 2) the word pending 3) and then a date in this format: year,month,day,hour,minute,second I would like to extract each in a variable. Examples: 7pending20110721170832 504pending20110720110107 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 21, 2011, at 3:15 PM, Leonel *.* wrote:> I have a string composed of three parts. > 1) a number, could be 1, 2, 3, 4 or more digits. > 2) the word pending > 3) and then a date in this format: year,month,day,hour,minute,second > > I would like to extract each in a variable. > > Examples: > > 7pending20110721170832 > 504pending20110720110107 >This is a good place to play http://rubular.com/ (\d) => capture a single digit (\w) => capture a single letter> -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Very easy :-) (\d+)(\w+)(\d{4})(\d{2})(\d{2} )(\d{2})(\d{2})(\d{2}) Tests... http://www.gethifi.com/tools/regex http://nregex.com/nregex/default.aspx http://regexpal.com/ 2011/7/21 Leonel *.* <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>> I have a string composed of three parts. > 1) a number, could be 1, 2, 3, 4 or more digits. > 2) the word pending > 3) and then a date in this format: year,month,day,hour,minute,second > > I would like to extract each in a variable. > > Examples: > > 7pending20110721170832 > 504pending20110720110107 > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Fernando Almeida www.fernandoalmeida.net -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.