I was looking at a C# Regex tutorial which stated that “\d” matches a single digit 0 to 9.
However when I ran the following program.
static void Main(string[] args)
{
string s = "45";
Regex myRegex = new Regex(@"(\d)");
if( myRegex.IsMatch(s))
{
System.Console.WriteLine("Matched");
}
else
{
System.Console.WriteLine("Not Matched");
}
Console.ReadKey();
}
The console printed out “Matched”.
1 Answer