![](/img/trans.png)
[英]Regex.Match returns different/wrong result in Unity compared to same exact code in a C# console app
[英]C# Regex Match gives wrong result
var hostName = "tenant1.example.be";
var match = Regex.Match(hostName, @"([A-Za-z0-9]+)\.example\.be$", RegexOptions.IgnoreCase);
var subdomain = match.Success ? match.Value : null;
子域的结果始终是: tenant1.example.be
而不是tenant1
。
任何人?
您只需要匹配的第一组:
var subdomain = match.Success ? match.Groups[1].Value : null;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.