How do I search for a word in a string which is in an array with different combinations?

I have an an array something like:

["Rob Meyer", "Michelle Preston"]

I want to search for an occurrence of rob or Rob, or meyer or Meyer and so on, any "word" in the array, no characters but just words and not case sensitive.

So how do I do that? include? looks for an exact match. I am looking for something that is more flexible here.


Is that what you are looking for?

query = 'rob'
["Rob Meyer", "Michelle Preston"].any?{|e| e =~ /\b#{query}\b/i}

Need Your Help

How do I find how C++ compiler implements something except inspecting emitted machine code?

c++ optimization compiler-construction assembly

Suppose I crafted a set of classes to abstract something and now I worry whether my C++ compiler will be able to peel off those wrappings and emit really clean, concise and fast code. How do I find...

Make Elements On A Visual Basic Form Draggable


I would like to make a Visual Basic Form that has a specified set of elements that can be dragged to another location on the form by the user. How can I do this? I have looked on Google, and done s...