import re
print(re.compile(r'<.*?>').split('hello<cr>there<cr>yu<bs>ou<cr>'))
Results in the list ['hello', 'there', 'yu', 'ou']. But what if I was also interested in what kind of <.*?>s I was dealing with? I can just sorround the split regex with parenthesis (as far as I know, this is a python specific thing), like so:
Take this python snippet:
Results in the list
['hello', 'there', 'yu', 'ou']
. But what if I was also interested in what kind of<.*?>
s I was dealing with? I can just sorround the split regex with parenthesis (as far as I know, this is a python specific thing), like so:This gets you:
['hello', '<cr>', 'there', '<cr>', 'yu', '<bs>', 'ou', '<cr>']
.Is there a way to reproduce this behaviour using this library?