Very simply. The best way to ascertain if a stretching exercise is hurting you is … wait for it … if it hurts to do it.
Your body is actually quite adept at letting you know if it is being hurt. It is “wired” with sensors that send your brain pain signals if damage is occurring. If a stretch you are doing results in a sharp twinge or an “uh-oh” kind of sensation, it is best to STOP that stretch, and to also leave off similar stretches to that muscle and its myotatic group (associated muscles).
Rest is to follow, as well as ice applied to those muscles (to reduce swelling and inflammation). An anti-inflammatory medication such as ibuprofen (Tylenol) may also be called for. If symptoms are severe, naproxen (Alleve) can be especially helpful in the short-term. Please consult a physician if you are not sure what to take or are concerned about drug interactions or side effects, or if you have other significant health issues.