I am not that good with regex and stuff. I know how to change http://google.com and www.google.com into links. However, I want my script to get links around the following strings:
Hello. Have you visited [link goes here]google.com[/link goes here] today?
Hello. Have you visited [link goes here]www.google.com[/link goes here] today?
Hello. Have you visited [link goes here]http://google.com[/link goes here] today?
Hello. Have you visited [link goes here]https://google.com[/link goes here] today?
Of course, I would really like the expression to allow as many characters as possible. But for the first link to work, I can only think of one explanation (I don't want people to start writing text.text and it will become a link):
<?php
$tlds = array("com", "net", "org", "info", "no", "dk", "se");
foreach($tlds as $tld){
$string = preg_replace("something", "something", $string);
}
?>
Do any of you know what to do? :P
I want it to be similar to Autolinker.js, only in PHP: https://github.com/gregjacobs/Autolinker.js