Last active
June 15, 2017 16:13
-
-
Save geoff-maddock/17432fa9c19f7483dd5c853b2f78b6b6 to your computer and use it in GitHub Desktop.
URL and Email addresses into LINKS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//show URLs as links | |
$part = preg_replace('/(?:https?:\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i', "<a href='$0'>$0</a>", $part); | |
//show email addresses as links | |
$part = preg_replace("/[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/i", "<a href='mailto:$0'>$0</a>", $part); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment