import reregex = r'\\i[\d{}]+'string = "\i{}Agrostis\i0{} <L.>" string = re.sub(regex, '', string)print string
Standard input is empty
Agrostis <L.>
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!