Extract digits from a string in Java

I have a Java String object. I need to extract only digits from it. I’ll give an example:

"123-456-789" I want "123456789"

Is there a library function that extracts only digits?

Thanks for the answers. Before I try these I need to know if I have to install any additional llibraries?

14 Answers
14

Leave a Comment