import re
parts = re.split(':|(-->)|,', '00:02:34...')



On Mon, Sep 28, 2015 at 5:10 PM, Niilos <niilos@gmx.com> wrote:
Hello everyone,

I was wondering how to split a string with multiple separators.
For instance, if I edit some subtitle file and I want the string '00:02:34,452 --> 00:02:37,927' to become ['00', '02', '34', '452', '00', '02', '37', '927'] I have to use split too much time and I didn't find a "clean" way to do it.
I imagined the split function with an iterator as parameter. The string would be split each time its substring is in the iterator.

Here is the syntax I considered for this :

>>> '00:02:34,452 --> 00:02:37,927'.split([ ':', ' --> ', ',' ])
['00', '02', '34', '452', '00', '02', '37', '927']

Is it a relevant idea ? What do you think about it ?

Regards,
Niilos.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/



--
Ryan
[ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.