Why is \\d in C# slower than [0-9]?
Hi everyone! I'm a beginner C# developer and encountered an unexpected problem when optimizing regular expressions.\n\nI have a task: check if a string consists only of digits. I wrote two regex variants:\n\n1. `^\\d+$`\n2. `^[0-9]+$`\n\nIntuitively, it seems like `\\d` should be faster or at least the same speed, since it's just a shorthand for digits. But I ran a small benchmark using `Stopwatch` on a 1000-character string (1000 random digits) and got shocking results:\n\n```\n\\d: ~450 ticks\n[0-9]: ~120 ticks\n```\n\nThe difference is almost 4 times! I ran the test 100 times to rule out randomness. The results are consistent.\n\nI'm using .NET 6, standard `Regex` without flags. Why is this happening? Both `\\d` and `[0-9]` should mean the same thing.