日期:2014-05-19 浏览次数:20677 次
String a = "//aaa"; System.out.println(a); Pattern pa = Pattern.compile("^(//)([a-zA-Z]+)"); Matcher ma = pa.matcher(a); if(ma.find()) System.out.println(ma.group(2));
------解决方案--------------------
String pattern="[\w]*";
这个是不是就可以啊
------解决方案--------------------
String a = "//aaa"; String b = "/bbb"; String c = "ccc"; Pattern pa = Pattern.compile("^[^([/]{2})]([a-zA-Z]+)"); Matcher ma = pa.matcher(a); Matcher mb = pa.matcher(b); Matcher mc = pa.matcher(c); if(ma.find()) System.out.println("ma="+ma.group()); if(mb.find()) System.out.println("mb="+mb.group()); if(mc.find()) System.out.println("mc="+mc.group());