The regex you need is /(.)1{9,}/
.
Test:
#!perl
use warnings;
use strict;
my $regex = qr/(.)1{9,}/;
print "NO" if "abcdefghijklmno" =~ $regex;
print "YES" if "------------------------" =~ $regex;
print "YES" if "========================" =~ $regex;
Here the 1
is called a backreference. It references what is captured by the dot .
between the brackets (.)
and then the {9,}
asks for nine or more of the same character. Thus this matches ten or more of any single character.
Although the above test script is in Perl, this is very standard regex syntax and should work in any language. In some variants you might need to use more backslashes, e.g. Emacs would make you write (.)1{9,}
here.
If a whole string should consist of 9 or more identical characters, add anchors around the pattern:
my $regex = qr/^(.)1{9,}$/;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…