re.split question

Steffen Ries steffen.ries at sympatico.ca
Thu Jun 22 07:36:48 EDT 2000


Hi,

I'm trying use re.split to separate an LDAP Distinguished Name into
its naming components. The naming components are of the form
"attr=value" and they are separated by ",".

The part, which I can't solve is, that "value" may contain the
sequence "\,", which obviously does not separate a naming component.

e.g.
"uid=joe, ou=orgunit, o=some org"
should be split into ["uid=joe", "ou=orgunit", "o=some org"]

"uid=joe, ou=org\\, unit, o=some org"
-> ["uid=joe", "ou=org\\, unit", "o=some org"]

Is there a way to use re.split to achieve this? (I solved it searching
[^\\], and splitting the string in a loop, but I was wondering if it
can be done easier.)

TIA,
/steffen
-- 
steffen.ries at sympatico.ca	<> Gravity is a myth -- the Earth sucks!



More information about the Python-list mailing list