Created
July 20, 2017 04:38
-
-
Save ellisio/1c6da4c8b3fa401d9ac66da9a3a20ce2 to your computer and use it in GitHub Desktop.
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
$ art tinker | |
Psy Shell v0.8.8 (PHP 7.1.6 — cli) by Justin Hileman | |
>>> $url = '@(http)?(s)?(://)?(([a-zA-Z])([-\w]+\.)+([^\s\.]+[^\s]*)+[^,.\s])@'; | |
=> "@(http)?(s)?(://)?(([a-zA-Z])([-\w]+\.)+([^\s\.]+[^\s]*)+[^,.\s])@" | |
>>> $string = 'superawesome.com'; | |
=> "superawesome.com" | |
>>> $string = preg_replace($url, '<a href="http$2://$4" target="_blank" title="$0">$0</a>', $string); | |
=> "<a href="https://uperawesome.com" target="_blank" title="superawesome.com">superawesome.com</a>" | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment