I have a long string. What is the regular expression to split the numbers into the array?
+1
A:
Are you removing or splitting? This will remove all the non-numeric characters.
myStr = myStr.replaceAll( "[^\\d]", "" )
Stefan Kendall
2009-10-07 19:35:55
+1
A:
You will want to use the String class' Split() method and pass in a regular expression of "\D+" which will match at least one non-number.
myString.split("\\D+");
Stephen Mesa
2009-10-07 19:37:32
This will remove all the numeric characters and give an array with all the non-numeric ones. It's exactly the opposite of the requested.
tangens
2009-10-07 19:46:54
Whoops, I must have misinterpreted what the question was. In that case it would be the negated version of the regex, which is \\D+I will update my answer!
Stephen Mesa
2009-10-07 20:05:27