php - Regex - remove 'a' tags where the link contains certain domains -


say have text so:

lorem ipsum <a href="http://www.youtube.com/watch?v=e6uso8krrmu">http://www.youtube.com/watch?v=e6uso8krrmu</a> blah blah blah <a href="http://www.google.com" target="_blank">google</a> it's hot outside  <a href="http://www.youtube.com/watch?v=e6uso8krrmu" class="class1 class2">http://www.youtube.com/watch?v=e6uso8krrmu</a> 

..and want remove link around if href attribute contains youtube - sake of example.

the output should be:

lorem ipsum http://www.youtube.com/watch?v=e6uso8krrmu blah blah blah <a href="http://www.google.com" target="_blank">google</a> it's hot outside  http://www.youtube.com/watch?v=e6uso8krrmu 

how can achieve this?

while have attention, if has links place start learning regex i'd love hear it.

$('a').filter(function() {     return $(this).attr('href').lastindexof('youtube') >= 0; }).contents().unwrap(); 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -