fork download
  1. import re
  2. s = '[*]\r\n[list][*][*][/list][*]text[list][*][/list]'
  3. match = re.compile('\[list].+?\[/list]', re.DOTALL)
  4. print(match.sub(lambda m: m.group().replace('*', '**'), s))
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
[*]
[list][**][**][/list][*]text[list][**][/list]