Reputation: 41
i have the regex ~[^\.]*\.[a-z]{3}$~
which matches test.net for following url over preg_match:
url.test.net
Now i need a regex which matches test.net for the following url:
p59027s1628.url.test.net
Can anyone help me with that?
Upvotes: 0
Views: 456
Reputation:
Try this regex:
(?<=url.).*$
Explaining:
(?<=url.) # looks for "url." - without taking it
.*$ # matches everything till the end
Hope it helps.
Upvotes: 1
Reputation: 107347
You can use following regex :
[^.]+\.[a-z]*\.[a-z]{3}$
See demo https://regex101.com/r/bV7tM6/1
Or more precise you can use following regex:
(?:[a-z]*\.){2}[a-z]{3}$
See demo https://regex101.com/r/bV7tM6/2
Upvotes: 1