- preg_replace: documentation ( source)
<?php
$string = "[[some_non-matching_text]] [[https://example.com|link]] [[this is not matching either]] [[http://example2.com|link2]]";
echo preg_replace('~\[\[((?:(?!\[\[).)*?)\|(.*?)]]~s', '<a href="$1">$2</a>', $string);