I am not good at regex.
I got this string with some html <a>
tags and i need to strip some of them out, but only <a>
tags containing a certain value in the "href" attribut (mysite.com).
I still need to keep the link text, like the php function strip_tags($string, "<a>")
Here is what I got so far.:
/<a href=["\']?(http:\/\/mysite.com[^"\'\s>]+)["\'\s>]?/i
This is also working, but the problem is that I can't get the "text" in fx. <a href="http://mysite.com/testing/something">"text"</a>
So the input.:
Lorem ipsum <a href="http://mysite.com/testing/something">dolor</a> sit amet, <a href="http://keepingThisLink.com">consectetur</a> adipiscing elit. Duis dignissim <a href="http://mysite.com/testing">golor</a> vitae turpis fermentum tincidunt.
Should output.:
Lorem ipsum dolor sit amet, <a href="http://keepingThisLink.com">consectetur</a> adipiscing elit. Duis dignissim golor vitae turpis fermentum tincidunt.