Hi I have a string “72\n” When I try to use Integer.parseInt(“72\n”) it gives me a log error, unable to parse’72 ‘ as integer. What can I do to filter out the \n?
Thanks
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.
replaceAllwith an appropriate regex should work well. For instance\\Dwill find all non-numeric characters, and somyString.replaceAll("\\D", "")could work well:This gets trickier if we allow for non-int floating point numbers which allow for locale dependent non-numeric chars such as a single
.for a decimal point in the usa and,in some other locations.