3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
23.59 ms | 404 KiB | 5 Q