If I have an array of Strings, how can I create a sub-array that contains only elements from the original array that contains the substring "yellow"?
1 Answer
You can use #grep method for this:-
# will give all strings have a sub-string `yellow` as a subarry
array.grep(/yellow/)