日期:2014-05-18  浏览次数:20692 次

求一正则表达式,获取当前页面
URL:http://localhost/post.do?paramId=1&paramName=name#top
在JAVA中用正则表达式获取到   post.do

------解决方案--------------------
public static String getHref(String href){
Pattern s=Pattern.compile( "http://localhost/(.*)\\? ");
Matcher m=s.matcher(href);
if(m.find())
return m.group(1);
else
return null;
}
------解决方案--------------------
http\:\/\/localhost\/\w+\.\w+|http\:\/\/((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?\/\w+\.\w+
这个正则表达式适用于http://localhost的和http://192.168.8.8这种的。希望对你有帮助