new to here. Would be grateful for any idea.
I need a REGEX to extract domains from a text. Text will contain emails and domains, with extracting email don’t have problems but with domains it is a bit tricky.
For example have a text consisting of emails and domains:
”
[email protected], google.com, www.msn.com, [email protected], [email protected], somesite.com, bbc.co.uk
“
Using REGEX: “[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}” I extract emails: [email protected], [email protected], [email protected].
Ok, but cannot find/build REGEX to extract domains only, found some in historic questions in here, but those getting also domains as part of emails, but I need to extract only domains when they are standalone but not as part of email address. Also taking into account such domains as with ‘co.uk’ or with also 2nd level domain+root domain. Just to have extracted:
”
google.com, www.msn.com, bbc.co.uk
”
from above given list of domains-emails.
Any idea is appreciated.
Thanks
Tried to find an answer here in different chats, but not specific my problem. Tried CHatGPT but not that smart enough yet to understand what I exactly need.
Timm P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.