ruby on rails - How do I search for a word in a string which is in an array with different combinations? -
i have an array like:
["rob meyer", "michelle preston"] i want search occurrence of rob or rob, or meyer or meyer , on, "word" in array, no characters words , not case sensitive.
so how do that? include? looks exact match. looking more flexible here.
is looking for?
query = 'rob' ["rob meyer", "michelle preston"].any?{|e| e =~ /\b#{query}\b/i}
Comments
Post a Comment