Extract links from content

I thought regex search may become critical so html dom parser may help. See the code below (if it helps):

<?php

$post_content = get_the_content();
$dom = new DomDocument();
$dom->loadHTML($post_content);
foreach ($dom->getElementsByTagName('a') as $item) {
   echo "<a href="https://wordpress.stackexchange.com/questions/315648/.$item->getAttribute("href')." target="_blank" rel="". $item->getAttribute("rel') ."'>". $item->getAttribute('title') ."</a><br />";
}

?>