Group(), Groups() & Groupdict()

  • + 1 comment

    \1 means the literal value of the value matched in the first group. The + sign right after that means "one or more" of those.

    In that sense, the whole expression reads as "an alphanumeric character that is followed by one or more characteres that are identical to it"

    That is very clever, as I did not realize "\1" could be used inside the matching expression.

    For reference: https://docs.python.org/3/library/re.html