I want to use {n} to specufy the number of occurence of a number in a string, but it seems have no effect. The following is my testing program---------------------------------------------using System;
using System.Text.RegularExpressions;public class Test
{
public static void Main(string[] args)
{
RegTest(args);
}
// --- paras[0]: string; paras[1]: regulaer expression
private static void RegTest(string[] paras)
{
if (Regex.IsMatch(paras[0], paras[1]))
Console.WriteLine("Input matches regular expression.");
else
Console.WriteLine("Input DOES NOT match regular expression.");
}
}---------------------------------------------
When you execute the program like the following test.exe aaaaaaaa ^a{5}$The program output is
Input matches regular expression.
I think aaaaaaaa does not match ^a{5}$, why the Regex.IsMatch consider it as a match???
Any thoughts, guys? Many thnx
using System.Text.RegularExpressions;public class Test
{
public static void Main(string[] args)
{
RegTest(args);
}
// --- paras[0]: string; paras[1]: regulaer expression
private static void RegTest(string[] paras)
{
if (Regex.IsMatch(paras[0], paras[1]))
Console.WriteLine("Input matches regular expression.");
else
Console.WriteLine("Input DOES NOT match regular expression.");
}
}---------------------------------------------
When you execute the program like the following test.exe aaaaaaaa ^a{5}$The program output is
Input matches regular expression.
I think aaaaaaaa does not match ^a{5}$, why the Regex.IsMatch consider it as a match???
Any thoughts, guys? Many thnx
Console.WriteLine("{0}", paras[1]);好像DOS把^吃掉了试一下test.exe aaaaaaaa "^a{5}$"