How to split the string into segments in python
python, string
Solution
Try re.findall:
import re
your_string = '<python><regex><split>'
parts = re.findall(r'<.+?>', your_string)
print parts # ['<python>', '<regex>', '<split>']
Problem
I have a string built from a few segments, which are not separated, but not overlap. This looks like that: ``` <python><regex><split> ``` I would like to split in into: ``` <python>, <regex>, <split> ``` I'm looking for the most efficient way to do that, and in the same time with as little code as possible. I could change '>' into '> ' etc., but I don't want to do any redundant operations. Is it possible to use regex to do that?