String url = "mysite.com/index.php?name=john&id=432"
How can I extract the id parameter (432)?
it can be in any position in the url and the length of the id varies too
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use Apache URLEncodedUtils from HttpClient package:
This print 42 to the console.
If you have the url stored in a URI object, you may find useful an overload of URLEncodedUtils.parse
that accept directly an URI instance. If you use this overloaded version, you have to give the charset as a string: