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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -