Group(), Groups() & Groupdict()

  • + 0 comments

    I managed to abuse the subscriptability of re.search:

    import re
    s = input()
    rx = re.compile(r"([a-zA-Z0-9])(?=\1)")
    print(rx.search(s)[0] if rx.search(s) else -1)