我需要验证用户输入的文本格式是否为:
####-#####-####-###
我可以使用Regex.Match吗?
private static readonly Regex _validator =
new Regex(@"^\d{4}-\d{5}-\d{4}-\d{3}$", RegexOptions.Compiled);
private static bool ValidateInput(string input)
{
input = (input ?? string.Empty);
if (input.Length != 19)
{
return false;
}
return _validator.IsMatch(input);
}
\u002d
让我以为 C♯ 可能会像 Java 一样存在 UTF-16 设计上的错误,导致代理码点出现问题。您是否知道 C♯ 是否存在这些问题? - tchrist