patternMatcher function

Controller function for pattern-matching