Hi guys,
I'm new to this forum and have a question. Though I sincerely hope I can help others also in the future.
The problem I am having is that I need to extract domains from some text. The text looks like this f.e.:
'iamadomain.com www.adomain.com www.faulty Domain.com www.Faulty domain I'm Not even a Domain, etc.'
So in this texts there are a lot of fault domains, I just need the domain 'iamadomain.com', so the domain without www. (or if there is a www., just the domain after it).
For this I wrote this regular expression:
if (preg_match("/^[a-zA-Z0-9]*((-|\.)?[a-zA-Z0-9])*\.([a-zA-Z]{2,4})$/", $domain))
{echo "$name found!\n"; break;}
But somehow this just does not work and I have no idea why. When I leave behind the ^ sign the output has the domains but also the non-domains in it.
Any idea?
Thanks! 🙂