|
发表于 2004-6-1 02:57:39
|
显示全部楼层
[PHP]
import java.util.regex.*;
public class StringCutting {
public static void main(String[] args) {
try {
String src = "CN=menglianjing,OU=ShanDong,O=ShanDong University";
java.util.regex.Pattern patt = Pattern.compile("(CN=\\w*).*");
System.out.println(patt.pattern());
Matcher mat = patt.matcher(src);
System.out.println(mat.matches());
System.out.println(mat.group(1));
System.out.println(mat.groupCount());
} catch (RuntimeException e) {
// TODO Auto-generated catch block
System.out.println (e.getMessage());
}
}
}
[/PHP] |
|