/^ (.)(?!\1) # any character not followed by itself (.)(?!\1|\2) # any character not followed by itself or previous (.)(?!\1|\2|\3) # likewise unique... (.)(?!\1|\2|\3|\4) (.) \3 (?!\1|\2|\3|\4|\5) # 6th character must be same as 3rd (.)(?!\1|\2|\3|\4|\5|\6) # 7th and 8th must be unique . $/x