I want to find out whether a char appears consecutively more than 2 times in a string, according to msdn, I ended up with this snippet:
string tripleRepetitiveCharPtn = @"(\w)\1\1";
Regex.IsMatch("45678au---lt", tripleRepetitiveCharPtn, RegexOptions.IgnoreCase)
{
...
}
It works for "aaa", but not "---". What should I do?
Thanks.
UPDATE:
Since the question was marked as [duplicated]-as a result, my reputation amount was reduced, I realized that the question is originally somehow vague. Thanks to all the gentle men who left answers/comments, it is now clear that why (\w) does not match hyphen symbol, thank you all.
But my intention was actually to find out a method to specify other chars in addition to (\w), I know that (.*) can match everything, however, can I specify them literally?