php - Symfony : detect link inside textarea -



php - Symfony : detect link inside textarea -

i trying observe links within textarea , display in view.

so tried these preg_replace instructions

preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$detail); preg_replace('@(http)?(s)?(://)?(([a-za-z])([-\w]+\.)+([^\s\.]+[^\s]*)+[^,.\s])@', '<a target="ref" href="http$2://$4">$1$2$3$4</a>', $detail);

and it's done great on whole except when got url containing special character follow :

http://website.info/x-y-z-a/~~~~dcvvvc|cvvcvc~~~/cvcvcv-5-1.html.

then it's not working @ all.

thanks

you encode url before running regex in order turn special characters % equivalent.

see http://php.net/manual/fr/function.urlencode.php

php regex

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -