Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove the non-numeric character from a string in java? [closed]

Tags:

java

regex

I have a long string. What is the regular expression to split the numbers into the array?

like image 861
unj2 Avatar asked Oct 07 '09 19:10

unj2


People also ask

How do I remove all non numeric characters from a string in Java?

str = str. replaceAll("[^\\d.]", "");

How do I remove non numeric characters from a string?

In order to remove all non-numeric characters from a string, replace() function is used. replace() Function: This function searches a string for a specific value, or a RegExp, and returns a new string where the replacement is done.


1 Answers

Are you removing or splitting? This will remove all the non-numeric characters.

myStr = myStr.replaceAll( "[^\\d]", "" ) 
like image 55
Stefan Kendall Avatar answered Oct 01 '22 19:10

Stefan Kendall