m = re.search('(?P<fp>.+)[0-9]{8}(?P<lp>.+)[0-9]{8}', st)
if m:
    print(m.group('fp') + rep1 + m.group('lp') + rep2)
else:
    print('no match...')
How to sub with matched groups and variables in Python