import re

def dump(match):
    start, end = match.span()
print(s[start:end + int(s[start + 1:end])])
re.sub('[-+]\\d+', dump, s)
regular expression that reference a match from earlier part of expression