fork download
  1. import java.util.*;
  2. import java.util.regex.*;
  3.  
  4. class Test
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String regex = "(?<=cn=)[^,|]+(?=,ou=tged,ou=groupes,o=choregie,c=fr)";
  9. String string = "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";
  10. Pattern pattern = Pattern.compile(regex);
  11. Matcher matcher = pattern.matcher(string);
  12. while (matcher.find()) {
  13. System.out.println(matcher.group(0));
  14. }
  15. }
  16. }
Success #stdin #stdout 0.09s 48032KB
stdin
Standard input is empty
stdout
doc_medical
doc_confidentiel