>> I have this string on a field >> CN=pointhairedpeoplethatsux,OU=Groups,OU=Hatepeople,OU=HR,DC=fabrika,DC=com;CN=pointhairedboss,OU=Groups,OU=Hatepeople,OU=HR,DC=fabrika,DC=com >> this string is all the groups one user has membership. >> So what I am trying to do. >> read this string >> and extract only the CNs >> >> like >> >> pointhairdepeoplethatsux,pointhairedboss > > >>> s = > "CN=pointhairedpeoplethatsux,OU=Groups,OU=Hatepeople,OU=HR,DC=fabrika,DC=com;CN=pointhairedboss,OU=Groups,OU=Hatepeople,OU=HR,DC=fabrika,DC=com"
Or, if you're a regexp junkie... >>> import re >>> r = re.compile('CN=([^;,]*)') >>> r.findall(s) ['pointhairedpeoplethatsux', 'pointhairedboss'] I'll leave timing comparisons as an exercise to the reader... ;) Both of these solutions make the assumption that neither a comma nor a semicolon are permissible in a CN. -tkc -- http://mail.python.org/mailman/listinfo/python-list