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