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?
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.