Suppose I have a String, say one two three one one two one.
Now I'm using a Pattern and a Matcher to find any specific Pattern in the String.
Like this:
Pattern findMyPattern = Pattern.compile("one");
Matcher foundAMatch = findMyPattern.matcher(myString);
while(foundAMatch.find())
// do my stuff
But, suppose I want to find multiple patterns. For the example String I took, I want to find both one and two. Now it's a quite small String,so probable solution is using another Pattern and find my matches. But, this is just a small example. Is there an efficient way to do it, instead of just trying it out in a loop over all the set of Patterns?