I'm making email addresses clickable with this code:
function makeemail($str) {
$str = preg_replace('/([\!~#$%&=?^*\/_\.\+0-9a-zæøå-]+)@(([0-9a-zæøå-]+\.)+[a-z]{2,12})/i', '<a href="mailto:$1@$2" title="">$1@$2</a>', $str);
return trim($str);
}
What can I do so it ignores text where "http://" and "https://" is part of it? (or maybe just "http", to be simple)
Some http server url's can have @ in the address, and I'm dealing with http url's in an other function.
I'm a bit of a regex noob. I tried adding ?!http:\/\/
or ?!https?:\/\/
with and without parantheses, but it doesn't work and it's out of my scope where/how to put it exactly.
emailaddress@example.com
- this should become <a href="mailto:email@address.com" title="">email@address.com</a>
(which it does perfectly)
http://userid:password@example.com:8080/
- this should be ignored and leaved as is because it contains http(s)://
)