m{ ([A-Za-z]) # find a letter (and capture it) \1 # followed by the same (?!\1) # but not by the same again }x; #### m{ (?: # either ^ # start of string | # or (.) (?!\1) # any character that is not followed by a duplicate ) # now proceed as before, keeping in mind this is now the second capture ([A-Za-z]) \2 (?!\2) }x;