I have this piece of regex that I’m using to create clickable links from URLs entered into a textarea. I did not write the code and am not sure how to modify it so that it will create links if the text starts with either http or https.
$html = preg_replace('"\b(http://\S+)"', '<a href="$1">$1</a>', stripslashes($rows['body']));
Adding a
?to the regex makes the preceding character optional.