hello i have laravel blade and here is the part that have the issue
@php
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
@endphp
<div class="message">
@php
$text = nl2br(e($message));
@endphp
@if(preg_match($reg_exUrl, $text, $url)){!! preg_replace($reg_exUrl, '<a href="$0" target="_blank">$0</a> ', $text) !!}
@else {!!$text!!}
@endif
</div>
this works good if the link is only in the text but if it got mixed with some words and some break line like this message
hello dear buyer
the link is working good https://google.com/blabla
and some random text
it converted to this html code
hello dear buyer<br>
<br>
the link is working good<br>
<a href="https://google.com/blabla<br" target="_blank">https://google.com/blabla<br< a=""> />
<br>
and some random text<br>
<br>
how to fix this
i want to replace the url into anchor tag and show the break line if the user enters message contains lines
also to use the e() function in blade to prevent any html code from running
any one help please