Reputation: 862
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.
Upvotes: 0
Views: 51
Reputation: 37419
Use find
:
words.find { |w| url[w] }
Example:
["hello", "World", "nice"].find { |w| "this is nice"[w] }
# => "nice"
Upvotes: 2