So based on this post
I have the following code which almost works, with the exception that clean is returning an error
syntax error, unexpected '0' (T_LNUMBER)
$url = '~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i';
$clean = str_replace(['https://', 'http://', 'www.'], '', $0);
$html = '<a href="$0" target="_blank" title="$0">'.$clean.'</a>';
$questionLinks = preg_replace($url, $html, $question->question);
The problem is with the $0, how can I have a normal variable to work with?