Finding patterns with rules