Here is a design though: For example is I put a link such as
http://example.com
in textarea. How do I get PHP t
While matching the full url spec is difficult, here's a regular expression that generally does a good job:
([\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?)
To use this in preg_replace, however, you need to escape it. As so:
$pattern = "/([\\w-]+(\\.[\\w-]+)*@([a-z0-9-]+(\\.[a-z0-9-]+)*?\\.[a-z]{2,6}|(\\d{1,3}\\.){3}\\d{1,3})(:\\d{4})?)/";
$replaced_texttext = preg_replace($pattern, '$0', $text);