detects matching patterns in text