class Program
{
static void Main(string[] args)
{
string str = "b";

var result1 = Regex.IsMatch(str, @"2");//字符串比较
var result2 = Regex.IsMatch(str, @"[0123456789]");//字符组穷举
var result3 = Regex.IsMatch(str, @"[0-9]");//范围
var result4 = Regex.IsMatch(str, @"^[0-9]$");//全字符串匹配
var result5 = Regex.IsMatch(str, @"^[0\-9]$");//元字符转义
var result6 = Regex.IsMatch(str, @"^[^0-9]$");//排除字符组
var result7 = Regex.IsMatch(str, @"^\d\w\s$");//简记字符组
var result8 = Regex.IsMatch(str, @"^[\d\w\s]$");//简记字符组,可以用在字符组内部
var result9 = Regex.IsMatch(str, @"^[\D\W\S]$");

//字符组运算
var result10 = Regex.IsMatch(str, @"^[a-z-[aeiou]]$");

 

Console.WriteLine(result10);

Console.ReadKey();
}
}

相关文章:

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