I’m trying to make a regular expression that matches on hostname in the url.
I want it to hit on de following hostnames:
– http://www.site.nl
– site.nl
I want it to return site.nl
I got this working with the following regex:
(?(?<=www.))site.(?:nl|be|eu)
However when I use this regex on something.site.nl it also returns site.nl. This is not what I want.
I only want a match when there is nothing before site.nl or when there’s www. before it.
I’ve tried a lot of different expressions but can’t figure out how I could do this.
I hope my question is clear and you guys can help me with this.
should work.
(Don’t forget the special meaning of dot in REs…)