How to search an array in Ruby?
Solution 1:
arr.grep(/^sa/)
Solution 2:
>> arr.select {|s| s.include? 'sa'}
=> ["sandra", "sam", "sabrina"]
arr.grep(/^sa/)
>> arr.select {|s| s.include? 'sa'}
=> ["sandra", "sam", "sabrina"]