How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

fl rxjwg98 at
Thu Jul 10 17:37:18 CEST 2014


This example is from the link:

I have thought about it quite a while without a clue yet. I notice that it uses
double quote ", in contrast to ' which I see more often until now.
It looks very complicated to me. Could you simplified it to a simple example?


import re
split_up = re.split(r"(\(\([^)]+\)\))",
                    "This is a ((test)) of the ((emergency broadcasting station.))")

...which produces:

["This is a ", "((test))", " of the ", "((emergency broadcasting station.))" ]

More information about the Python-list mailing list