Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
谁能帮我找到以worldpay.com或rbsworldpay.com结尾的域名
IPHostEntry entry = Dns.GetHostEntry(givenip); var hostName = entry.HostName.ToLower();
现在我想确保 hostName 仅以 worldpay.com 或 rbsworldpay.com 结尾,其他我想抛出异常的东西。
任何人都可以帮忙。
连正则表达式检查都应该做什么?
谢谢
试试这个代码:
if(hostName.EndsWith("worldpay.com")||hostName.EndsWith("rbsworldpay.com") { throw new Exception("wrong host"); }
以orhostName结尾时会抛出新的异常worldpay.comrbsworldpay.com
hostName
worldpay.com
rbsworldpay.com