re.split question
Steffen Ries
steffen.ries at sympatico.ca
Thu Jun 29 07:34:34 EDT 2000
mrw065 at merle.acns.nwu.edu (Mitchell R Whorlow) writes:
> How about using re.findall?
Hmm, hadn't thought about that one, but it looks like it gives me I
was expecting from re.split.
> >>> s = r"""id=joe, ou=org\, unit, o=some org"""
> >>> print s
> id=joe, ou=org\, unit, o=some org
> >>> patt = re.compile(r"""([^, ]+=[\w ]+(?:\\,)?[^,]+)""")
This regex finds only one \, the following does what I want:
patt = re.compile(r"([^, ]+=(?:(?:\\,)|[^,])+)")
> >>> patt.findall(s)
> ['id=joe', 'ou=org\\, unit', 'o=some org']
>
> I think this does what you want, but taking into account the regex I used,
> you still may prefer your solution.
Actually, I found the proper method in ldapmodule, so I don't have to
mess around with regex...
thanks to everybody who helped.
/steffen
--
steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks!
More information about the Python-list
mailing list