Delete Everything(the rest of the text) after a specific string
<p>How can i delete Everything after a string like 'gnirts'. this might give you a better understanding:
<a href="http://i.stack.imgur.com/iMjPW.png" rel="noreferrer">Before</a></p>

<p><a href="http://i.stack.imgur.com/b1Y6T.png" rel="noreferrer">and after</a></p>