I have a array of few string
For ex: ["hello", "World", "nice"]
Now i have a long url string with special string.
I want to find out which string from above array is present in my url string using Ruby and return that string.
Use find:
words.find { |w| url[w] }
Example:
["hello", "World", "nice"].find { |w| "this is nice"[w] }
# => "nice"
find/detect will return the first match only. The methods find_all/select are available if one needs all the values that match.
eachand check to see if it's in the URL. What's the specific issue? What have you tried so far?|and do a regex. Then do the relevant performance tests. Then ponder if the time you wasted was actually worth it.