-1

I'm new to Java. How I can get only the numbers from this String:

folder333

Can you show me some basic example?

Also I would like to do this with Java 8.

Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
  • What is number in your case? integer? Do you accept hexadeimal ones (e.g `0x456`)? Float? Should minuses (if any) be included into the number(s)? Could you provide a good test expample? – Dmitry Bychenko Mar 03 '15 at 10:48
  • Possible duplicate of http://stackoverflow.com/questions/14974033/extract-digits-from-string-stringutils-java or http://stackoverflow.com/questions/1903252/extract-integer-part-in-string or http://stackoverflow.com/questions/2367381/extract-numbers-from-a-string-java – OO7 Mar 03 '15 at 10:53

1 Answers1

4

Try something like:

String number = str.replaceAll("^[a-zA-Z]*", "");
SMA
  • 36,381
  • 8
  • 49
  • 73