[英]Regex to match everything from url but without subdomain
i have the regex ~[^\\.]*\\.[az]{3}$~
which matches test.net for following url over preg_match: 我有正则表达式
~[^\\.]*\\.[az]{3}$~
,它与test.net匹配,用于通过preg_match跟踪以下网址:
url.test.net
Now i need a regex which matches test.net for the following url: 现在,我需要一个与test.net相匹配的正则表达式,用于以下网址:
p59027s1628.url.test.net
Can anyone help me with that? 有人可以帮我吗?
Try this regex: 试试这个正则表达式:
(?<=url.).*$
Explaining: 说明:
(?<=url.) # looks for "url." - without taking it
.*$ # matches everything till the end
Hope it helps. 希望能帮助到你。
You can use following regex : 您可以使用以下正则表达式:
[^.]+\.[a-z]*\.[a-z]{3}$
See demo https://regex101.com/r/bV7tM6/1 参见演示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 参见演示https://regex101.com/r/bV7tM6/2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.