Reputation: 3042
I connected to a site using URLConnection and the result I'm looking for is the url inside these parenthesis: callback_request("https://secure.runescape.com/m=displaynames/s=bOVZmsrjbNQzntbDei*324JUo*3ozJ7hR*h1KNlxc6kPaBeKCBrdKIxD*edhi4qH/check_name.ws?displayname=" + escape(text), handleResult);
The problem I'm having is the : s=bOVZmsrjbNQzntbDei*324JUo*3ozJ7hR*h1KNlxc6kPaBeKCBrdKIxD*edhi4qH
is random each time--it's the session.
How can I use a regex expression to scan the page and look for https://secure.runescape.com/m=displaynames/(random_session_id)/check_name.ws?displayname=
?
Upvotes: 0
Views: 129
Reputation: 301527
Something like:
"https://secure\.runescape\.com/m=displaynames/s=[a-zA-Z1-9*]+/check_name\.ws\?displayname="
Upvotes: 1
Reputation: 13984
Try this:
import java.util.regex.Pattern;
public class Regex {
public static void main(String[] args)
{
Pattern p = Pattern.compile("https://secure\\.runescape\\.com/m=displaynames/.*/check_name\\.ws\\?displayname=\\?");
System.out.println(p.matcher("https://secure.runescape.com/m=displaynames/s=bOVZmsrjbNQzntbDei*324JUo*3ozJ7hR*h1KNlxc6kPaBeKCBrdKIxD*edhi4qH/check_name.ws?displayname=?").find());
}
}
Upvotes: 1
Reputation: 533870
If you know displayname will be last you can
String displayName = url.split("displayname=")[1];
Upvotes: 1