python regex split keeping matched strings added by caolanm on Fri Jan 12 18:25:11 2018
>>> import re >>> re.split("\{\{|\}\}", "one {{two}} three") ['one ', 'two', ' three'] >>> re.split("(\{\{|\}\})", "one {{two}} three") ['one ', '{{', 'two', '}}', ' three']