I have a website where I have an editor (html) only q sometimes instead of using the button to post the link people paste the link and it gets into text so I'm a regular expression to convert the text to link
$reply = preg_replace(
"/(?<![\>https?:\/\/|href=\"'])(?<http>(https?:[\/][\/]|www\.)([a-z]|[A-Z]|[0-9]|[\/.&?= ]|[~])*)/",
"<a href=\"$1\">$1</a>",
$reply
);
It happens that if the link has "-"
this link does not work, it cuts into "-"