fork download
  1. import re
  2. d = {'ShFrm':'Shortform', 'LgFrm':'Longform' ,'Auto':'Automatik'}
  3. col = ['ShFrmLgFrm should be replaced Automatically','Auto', 'AutoLgFrm']
  4. rx = r'(?:\b|(?<=[a-z]))(?:{})(?=[A-Z]|\b)'.format("|".join(d.keys()))
  5. print(rx)
  6. print([re.sub(rx, lambda x: d[x.group()], v) for v in col])
Success #stdin #stdout 0.02s 9504KB
stdin
Standard input is empty
stdout
(?:\b|(?<=[a-z]))(?:ShFrm|LgFrm|Auto)(?=[A-Z]|\b)
['ShortformLongform should be replaced Automatically', 'Automatik', 'AutomatikLongform']