0

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=?

3 Answers 3

1

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());
    }
}
Sign up to request clarification or add additional context in comments.

Comments

1

If you know displayname will be last you can

String displayName = url.split("displayname=")[1];

Comments

1

Something like:

"https://secure\.runescape\.com/m=displaynames/s=[a-zA-Z1-9*]+/check_name\.ws\?displayname="

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.