Skip to main content
3 of 4
Active reading.
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

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.

Thijser
  • 2.6k
  • 1
  • 40
  • 76