Search string for occurneces of words stored in array



Hi,

I have a sentence "This is my test sentence" and an array["is", "the",
"my"] and what i need to do is find the occurence of any of thearray
words in the sentence.

I have this working in a loop but i was wondering is there a way to do
it using one of rubys string methods.

Its sililar to the include method but searching for multiple words not
just one.

"This is my test sentence".include?("This") returns true

but i want something like

"This is my test sentence".include?("This", "is", "my")

anyone got a nice way to do this? I only need to find if one of the
words occure and then i exit.

JB
--
Posted via http://www.ruby-forum.com/.

.



Relevant Pages