// all the patterns that are going to have to be matched
String [] array = {"bfg", "fgj", "cde", "efg", "ght"};
Matcher m;
// scans trough each pattern
for(int i = 0; i < array.length; i++) {
// creates a new pattern for each element in the array
Pattern p = Pattern.compile(array[i]);
// attepts to match the created pattern to the specified string
m = p.matcher("abcdefg");
// if the pattern matches: print
if (m.find())
System.out.println(array[i] + " is contained");
}