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
In reply to Re: pattern matching in array
by hdb
in thread pattern matching in array
by torres09
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |