mikegray.397 mikegray.397 - 8 months ago 44
Python Question

Removing OU from group of ous using python

iam looking for python code to remove "var1" from "ougrpstr", please note that both variables will change i just want to strip var1 string from group.
basically "var1" representing a user and i am trying remove that user from a particular group.

var1= cn=656067688988,cn=Subscribers,cn=inc,cn=apac,cn=dac,cn=Resources,cn=Users,cn=OSILA
ougrpstr= "cn=656067689862,cn=Subscribers,cn=inc,cn=apac,cn=dac,cn=Resources,cn=Users,cn=OSILA;cn=656067680730,cn=Subscribers,cn=inc,cn=apac,cn=dac,cn=Resources,cn=Users,cn=OSILA;cn=656067688988,cn=Subscribers,cn=inc,cn=apac,cn=dac,cn=Resources,cn=Users,cn=OSILA;cn=656067686985,cn=Subscribers,cn=inc,cn=apac,cn=dac,cn=Resources,cn=Users,cn=OSILA"

cco cco

If an exact (case-dependent) match is OK, then you can use replace, as in:

newstr = ougrpstr.replace(var1, '')