支付宝JAVA笔试题 编程题:将一个网址的中间部分截取出来,得到alipay.com 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 String url = "http://topic.csdn.net/u/20091019/10/f8173f20-5eda-438b-a8ae-17e3ff9ec94e.html?40383"; String pattern = "(http://)?([^/]*)(/?.*)"; System.out.println(url.replaceAll(pattern, "$2")); private static void p(String s) { Pattern p=Pattern.compile("alipay[.]com"); Matcher m=p.matcher(s); while(m.find()){ System.out.println(m.group()); System.out.println(m.start()); } $2 代表第二个子匹配([^/]*),相应的$3代表第三个,子匹配是以左括号“(”开始从左向右匹配的。understand? Hibernate中get与load的区别.? JAVA IO异常帮忙解决下(急)!!! 多线程同时操作不同的对象会引起意想不到的结果吗?为什么 初步研究Session Bean,画了两张类图,大家一起来探讨,指正 我是菜鸟,想学j2ee,希望有经验的人给我点学习建议 请教各位,关于应用服务器的选用问题 想写一个小的辅助调试工具,请大家给个建议!来者有分!!! ssh整合问题 怎么动态存储图片路径到数据库 后台定义的枚举js如何取值 spring的IOC与对象实例化有何区别????????? s2sh,乱码问题
String pattern = "(http://)?([^/]*)(/?.*)";
System.out.println(url.replaceAll(pattern, "$2"));
Pattern p=Pattern.compile("alipay[.]com");
Matcher m=p.matcher(s);
while(m.find()){
System.out.println(m.group());
System.out.println(m.start());
}
$2 代表第二个子匹配([^/]*),相应的$3代表第三个,子匹配是以左括号“(”开始从左向右匹配的。understand?