in reply to pattern matching in array
For an array, have a look at grep. The example in there is almost what you need.
UPDATE: see here: Re^3: using grep to find a word