<html><head> <title> </title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="description" content="497"></head><body><script language="JavaScript"> location.href="https://172.16.250.11/mw0202/my/default.do?siteurl=callbacktest";</script>
</body></html>以上是一段html,现在我想分离出来location.href的内容( 一个url地址:https://172.16.250.11/mw0202/my/default.do?siteurl=callbacktest)
各位有什么好的,比较通用的办法,当然这个url是可以有很多种情况的,比如包含一些特殊字符什么的.
<meta name="description" content="497"></head><body><script language="JavaScript"> location.href="https://172.16.250.11/mw0202/my/default.do?siteurl=callbacktest";</script>
</body></html>以上是一段html,现在我想分离出来location.href的内容( 一个url地址:https://172.16.250.11/mw0202/my/default.do?siteurl=callbacktest)
各位有什么好的,比较通用的办法,当然这个url是可以有很多种情况的,比如包含一些特殊字符什么的.
解决方案 »
- 100分求救!!一道很简单的题目
- 关于Thinking in java中作者自己定义的类
- N皇后问题
- java socket和c通信时丢失数据是什么原因?
- 求一个成员方法重载的例子
- 请教下Java中加载与不加载的区别
- 关于删除JComboBox中项的问题.
- 数据库中存取datetime型字段怎么实现 !!!!急急急急急急!!!!!!
- 在php论坛看到的是那个面试~用java方法
- 通过网络传送整个文件夹的问题
- 怎样显示ftp服务器端的文件目录啊,苦求………………!!
- [求助]怎样用URLConnection 类,建立与http服务器的连接后,再检验http服务器返回的状态代码,如200,500,401用户名密码错误等?
int j = s.indexOf("</script>");String result = s.substring(i,j-2);
{
private String pattern;
private String match;
public Test()
{
}
public Test(String pattern,String match)
{
this.pattern=pattern;
this.match=match;
}
/**
* @return 返回 match。
*/
public String getMatch()
{
return match;
}
/**
* @param match 要设置的 match。
*/
public void setMatch(String match)
{
this.match=match;
}
/**
* @return 返回 pattern。
*/
public String getPattern()
{
return pattern;
}
/**
* @param pattern 要设置的 pattern。
*/
public void setPattern(String pattern)
{
this.pattern=pattern;
}
public void print()
{
Pattern p=Pattern.compile(pattern);
Matcher result=p.matcher(match);
while(result.find())
System.out.println(result.group());
}
public static void main(String[] args) throws Exception
{
Test t=new Test();
String pattern="location.href=https://([A-z/.=?]*\\d*)*"; String match="location.href=https://172.16.250.11/mw0202/my/default.do?siteurl=callbacktest";
t.setMatch(match);
t.setPattern(pattern);
t.print();
}
}
Matcher m = p.matcher("location.href=\"as.awe.rw\"");
while(m.find()){
System.out.println(m.group(1));
}