Search string for occurneces of words stored in array
- From: John Butler <johnnybutler7@xxxxxxxxx>
- Date: Wed, 30 Apr 2008 09:01:11 -0500
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/.
.
- Follow-Ups:
- Re: Search string for occurneces of words stored in array
- From: Roger Pack
- Re: Search string for occurneces of words stored in array
- From: Ken Bloom
- Re: Search string for occurneces of words stored in array
- From: David A. Black
- Re: Search string for occurneces of words stored in array
- From: Phillip Gawlowski
- Re: Search string for occurneces of words stored in array
- Prev by Date: Re: How to create "def method(item)= (value)" ?
- Next by Date: Re: How to create "def method(item)= (value)" ?
- Previous by thread: How to create "def method(item)= (value)" ?
- Next by thread: Re: Search string for occurneces of words stored in array
- Index(es):
Relevant Pages
|