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

fl rxjwg98 at gmail.com
Thu Jul 10 11:37:18 EDT 2014


Hi,

This example is from the link:

https://wiki.python.org/moin/RegularExpression


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?


Thanks,





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