fork download
  1. import re
  2. from itertools import count
  3.  
  4. line = r'#Совп. А# ... #Совп. Б# ... #Совп. В#'
  5. counter = count(1)
  6. line = re.sub(r'#[^#]*#', lambda x: '<{0}>{1}</{0}>'.format(str(next(counter)),x.group()), line)
  7. print(line)
Success #stdin #stdout 0.04s 9412KB
stdin
Standard input is empty
stdout
<1>#Совп. А#</1> ... <2>#Совп. Б#</2> ... <3>#Совп. В#</3>