I want to find integer value from a string. For example, given a String like “Ahmedabad to Gandhinagar Distance:29km(about 31 mins)”
I want to fetch only 29 from the given String because i want to compare this 29 kilometers to other kilometers.
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.
In C#, you can use a Regex.Match to pull out substrings if you use groups in the regex (note this is not tested…). There is probably a similar mechanism in Java, but I don’t know it off the top of my head: