String regex = ".*/(.+)\\?.*$";
String str = "jdbc:mysql://localhost:3306/student?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(str);
boolean rs = m.find();
for (int i = 1; i <= m.groupCount(); i++) {
System.out.println(i + ":[" + m.group(i) + "]");
}
String str = "jdbc:mysql://localhost:3306/student?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(str);
boolean rs = m.find();
for (int i = 1; i <= m.groupCount(); i++) {
System.out.println(i + ":[" + m.group(i) + "]");
}
解决方案 »
- struts如何实现restful样式的url风格?
- List转化问题
- 高手门,帮忙看看代码哪里错了,折磨我好几天!!!
- ssh对从数据库中读出数据的处理问题
- struts中如何用利用session防止用户连接到非法URL
- POI or Jexcel API的问题,想作导入导出excel数据的东西
- Help:自定义类型转换的问题
- HTML中带有"'"单引号,在插入数据库时出错,各位是如何解决的?
- 如何在JSP软件中使用音序实现字典或词典查询,其中的SQL语句来怎么写???比如输入QMS、FKQJP、PEM……时,得到青霉素、妇科千金片、扑
- String型怎么转换成int,数组是否可以a[i],i为变量来表示?
- 奇怪了
- 一天到晚迷体育,我完了,也许是我没有进步的原因
public class tt
{
public static void main(String[] args){
String str= "jdbc:mysql://localhost:3306/student?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false";
String str1 = str.substring((str.lastIndexOf("/")+1),(str.lastIndexOf("?")));
System.out.println(str1);
}
}
还是非常感谢你啊
如果 IDE 是 Eclipse / Jdeveloper 之类的,你还可以直接把源码绑定到 .jar 上面,以后直接从菜单或 快捷键就能看 你想看的个别的类的 JavaDocs或源码 。