I need to match the “base” url, what I mean is:
Not match --> http://google.com
Not match --> http://www.google.com
Not match --> www.google.com
Match! --> google.com
I was trying to use a negative look behind to make sure there was no http:// or www, but it didn’t seem to work correctly.
Do this has to be with only one regex?
You could have the first regex that will match all URLs found. Something like that:
And then filter all matches and keep the ones that do not match the following:
although to be honest, I wouldn’t use Regex unless it is strictly necessary for that.
Note:
You can always find a better regex to match the URLs. The thing here is that they may not start with
http://orwww, so we can’t restrict the regex so much. Be ready to have other matches that are not urls at all, like:yesterday.butinI was there yesterday.but no one saw me