正则指引-量词demo

class Program
{
static void Main(string[] args)
{
string str = "1"3";
var re1 = Regex.IsMatch(str, @"^dddddd$");//数字出现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();
}
}

原文地址:https://www.cnblogs.com/lmfeng/p/3337499.html