fork(4) download
  1. import re
  2. t = 'String_BA22_FR22_BC'
  3. print(re.sub(r'FR\d+', 'FR', t))
  4. print(re.sub(r'(FR)\d+', r'\1', t))
Success #stdin #stdout 0.02s 27792KB
stdin
Standard input is empty
stdout
String_BA22_FR_BC
String_BA22_FR_BC