How can I get the int value from a string such as 423e – i.e. a string that contains a number but also maybe a letter?
Integer.parseInt() fails since the string must be entirely a number.
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.
Replace all non-digit with blank: the remaining string contains only digits.
This will also remove non-digits inbetween digits, so
"x1x1x"becomes11.If you need to confirm that the string consists of a sequence of digits (at least one) possibly followed a letter, then use this: