Pattern p = Pattern.compile("CN=(\\S*?),"); Matcher match = p.matcher(cert.getSubjectDN().getName()); if (match.find()){ System.out.println(match.group(1)); }
待查找的字符串内容:
CN=511027XXX01027325X, OU=UCIT, O=Soft
需要查找出:511027XXX01027325X
Pattern p = Pattern.compile("CN=(\\S*?),"); Matcher match = p.matcher(cert.getSubjectDN().getName()); if (match.find()){ System.out.println(match.group(1)); }
待查找的字符串内容:
CN=511027XXX01027325X, OU=UCIT, O=Soft
需要查找出:511027XXX01027325X