PHP turn URL or Email into link if not exist alrea

Run Settings
LanguagePHP
Language Version
Run Command
<?php $link_html = 'This link already exits: <a href="http://googele.com" target="_blank">link</a> but not this: http://google.com link or https://google.com. Email already in a link <a href="mailto:some@email.com">some@email.com</a> and one not: first.last@alink.com.'; // The beauty of this is it will also not include ending punctuation (!,.) and works with name.last@email.com function replace_links( $content ){ $content = preg_replace('"<a[^>]+>.+?</a>(*SKIP)(*FAIL)|(https?:\/\/\S+?)(?=[.,!?]?(\s|$))"', '<a href="$0">$0</a>', $content); $content = preg_replace('"<a[^>]+>.+?</a>(*SKIP)(*FAIL)|(\S+@\S+\.\S+?)(?=[.,!?]?(\s|$))"', '<a href="mailto:$0">$0</a>', $content); return $content; } echo replace_links( $link_html );
Editor Settings
Theme
Key bindings
Full width
Lines