Ganesh Ganesh wrote:
Is there any ruby supported methods is there for searching a word in a
For Example "Hi this is for test"
i need to search "Hi"
Scan is the more appropriate method:
irb(main):001:0> s = "Hi this is for test"
=> "Hi this is for test"
=> ["Hi"] # creates an array if the required word matches
Otherwise you can use regexp with a conditional:
irb(main):003:0> if s=~ /Hi/
irb(main):004:1> puts "found"
include? is another solution:
Posted via http://www.ruby-forum.com/.