There is such a code, it works, but if there is <br /> , then particles from <br /> added to the url
$new_text = preg_replace("~(http|https|ftp|ftps)://(.*?)(\s|\n|[,.?!](\s|\n)|$)~", '<a href="$1://$2">$1://$2</a>$3', $text); return $new_text; For example, the link https://www.google.com/ If it is written in the text like this
That all works.
If it is written in the text like this
Find on Google - https://www.google.com/ Google Website
That all works.
If it is written in the text like this
Find in Google https://www.google.com/
<br/>
To Google
That link absorbs the particles.
and all that comes after her.
How to fix it? And is it possible to redirect from a link to a specific page in order to check whether this domain is allowed for the transition, etc.
Desirable with an explanation.