I feel like this is trivial but can't find any solution that works for me.
I have a string of this sort :
cn=doc_medical,ou=tged,ou=groupes,o=choregie,c=fr|cn=test,ou=test,ou=test,o=choregie,c=fr|cn=doc_confidentiel,ou=tged,ou=groupes,o=choregie,c=fr|cn=test,ou=test,ou=test,o=choregie,c=fr
Where I need to to find the value between cn= and ,ou=tged,ou=groupes,o=choregie,c=fr, in this case I should only match doc_medical first and doc_confidentiel then.
I have this regex : (?=cn=)(.*?)(?<=,ou=tged,ou=groupes,o=choregie,c=fr) but the problem is that it obviously matches everything after the second cn= of the global string until the next ,ou=tged,ou=groupes,o=choregie,c=fr. So my second group is wrong because it contains cn=test,ou=test,ou=test,o=choregie,c=fr|cn=doc_confidentiel,ou=tged,ou=groupes,o=choregie,c=fr instead of only doc_confidentiel.
I don't know the number of character there can be between the two strings, and I can't seem to figure out how to force the regex to match the first cn= previous to the ,ou=tged,ou=groupes,o=choregie,c=fr string instead of the first one it encounters after it.