You can also begin by removing all non-numerical characters and then parsing the int:
string mystr = mystr.replaceAll( "[^\\d]", "" ); int number= Integer.parseInt(mystr); But be warned that this only works for non-negative numbers.
You can also begin by removing all non-numerical characters and then parsing the int:
string mystr = mystr.replaceAll( "[^\\d]", "" ); int number= Integer.parseInt(mystr); But be warned that this only works for non-negative numbers.