Skip to content

Instantly share code, notes, and snippets.

@khanof89
Created October 30, 2016 06:51
Show Gist options
  • Save khanof89/14fc19d0b0fa0f2bc0f1811894906f8e to your computer and use it in GitHub Desktop.
Save khanof89/14fc19d0b0fa0f2bc0f1811894906f8e to your computer and use it in GitHub Desktop.
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#!?&//=]+)',
'<a href="\\1" target="_blank">\\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#!?&//=]+)',
'\\1<a href="http://\\2" target="_blank">\\2</a>', $text);
$text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})',
'<a href="mailto:\\1">\\1</a>', $text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment