Hi, I am new to ruby and to programming in general. I am learning from an outdated book and just realized that the .grip method can no longer be used on strings since ruby 1.9. My question is could you please recommend an alternative method that I could use instead of grep and works on strings? Sincerely, Lorant -- 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 Apr 19, 2012, at 3:00 PM, Loren wrote:> Hi, > > > I am new to ruby and to programming in general. > I am learning from an outdated book and just realized that the .grip > method can no longer be used on strings since ruby 1.9. > > My question is could you please recommend an alternative method that I > could use instead of grep and works on strings?---- not sure that there was a ''grep'' in any version of ruby but .include? tends to be useful irb(main):001:0> test = "check" => "check" irb(main):002:0> string = "This is a string with a bunch of words which I can use to check" => "This is a string with a bunch of words which I can use to check" irb(main):003:0> string.include?(test) => true irb(main):004:0> test = "failure" => "failure" irb(main):005:0> string.include?(test) => false Craig -- 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.
Old: string.grep(/re/) New: string =~ /re/ On Apr 19, 6:00 pm, Loren <loren.bo...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Hi, > > I am new to ruby and to programming in general. > I am learning from an outdated book and just realized that the .grip > method can no longer be used on strings since ruby 1.9. > > My question is could you please recommend an alternative method that I > could use instead of grep and works on strings? > > Sincerely, > > Lorant-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.