我想从此IndiaRoute
检索919820673883
和URL
。
如何使用Pattern
和Matcher
?
如果还有其他方法可以做,那就建议我使用该片段。
这是我的网址
http://localhost:8080/IndiaRoute/servlet/SendSMPPClient?mno=919820673883&msg=xxx&sid=xxxx+&mt=0
事先提前
答案 0 :(得分:0)
Pattern p = Pattern.compile("http://.+/(.+?)/.+/.+\\?mno=(.+?)&");
String s = "http://localhost:8080/IndiaRoute/servlet/SendSMPPClient?mno=919820673883&msg=xxx&sid=xxxx+&mt=0";
java.util.regex.Matcher m = p.matcher(s);
if(m.find())
{
System.out.println(m.group(1));
System.out.println(m.group(2));
}
这将完成工作,直到网址中没有任何内容发生变化。
编辑:输出
IndiaRoute
919820673883