class Program
{
static void Main(string[] args)
{
string str = "1\"3";
var re1 = Regex.IsMatch(str, @"^\d\d\d\d\d\d$");//数字出现6次
var re2 = Regex.IsMatch(str, @"^\d{6}$");//使用量词
var re3 = Regex.IsMatch(str, @"^\d{6,10}$");//使用量词范围
var re4 = Regex.IsMatch(str, @"^\d{6,}$");//使用量词范围,无上限
//常用量词:*+?
var re5 = Regex.IsMatch(str, @"^travell?er$");//?:不出现或出现一次
var re6 = Regex.IsMatch(str, @"^100.3*$");//*:不出现或出现
var re7 = Regex.IsMatch(str, @"^100.3+$");//+:至少出现一次
var re8 = Regex.IsMatch(str, @"^.+$");//.匹配任意字符

Console.WriteLine(re8);
Console.ReadKey();
}
}

相关文章:

  • 2022-02-23
  • 2021-06-24
  • 2022-12-23
  • 2022-03-10
  • 2022-12-23
  • 2021-12-31
  • 2021-12-12
  • 2022-12-23
猜你喜欢
  • 2022-01-20
  • 2022-02-26
  • 2022-12-23
  • 2021-09-26
  • 2022-02-07
  • 2021-08-31
  • 2021-09-05
相关资源
相似解决方案