Skip to content
This repository has been archived by the owner on Oct 16, 2022. It is now read-only.

Split retaining split pattern #15

Open
Bietola opened this issue May 8, 2021 · 0 comments
Open

Split retaining split pattern #15

Bietola opened this issue May 8, 2021 · 0 comments

Comments

@Bietola
Copy link

Bietola commented May 8, 2021

Take this python snippet:

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:

print(re.compile(r'(<.*?>)').split('hello<cr>there<cr>yu<bs>ou<cr>'))

This gets you: ['hello', '<cr>', 'there', '<cr>', 'yu', '<bs>', 'ou', '<cr>'].

Is there a way to reproduce this behaviour using this library?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant