How can I find repeated letters with a Perl regex?

后端 未结 11 1310
孤独总比滥情好
孤独总比滥情好 2020-12-09 03:18

I am looking for a regex that will find repeating letters. So any letter twice or more, for example:

booooooot or abbott

I won\'t know the

11条回答
  •  情歌与酒
    2020-12-09 03:43

    Just for kicks, a completely different approach:

    if ( ($str ^ substr($str,1) ) =~ /\0+/ ) {
        print "found ", substr($str, $-[0], $+[0]-$-[0]+1), " at offset ", $-[0];
    }
    

提交回复
热议问题