Enumerable#grep
Ruby enumerables respond to grep
. You can use it to quickly filter a collection with a regular expression.
['Marta', 'Mario', 'Bill'].grep(/Ma/)
# => ['Marta', 'Mario']
Ruby enumerables respond to grep
. You can use it to quickly filter a collection with a regular expression.
['Marta', 'Mario', 'Bill'].grep(/Ma/)
# => ['Marta', 'Mario']