If you're getting unexpected matches, it could be because you've used a greedy quantifier, which matches as much as possible. Try using a non-greedy quantifier instead. You should also check that your pattern isn't too broad and matches more than you intended.