I'm trying to exclude integers of a String which can be negative. I have tried this :
String numbersExcluded=input.replaceAll("[^-?0-9]+"," ");
String[] stringOfNumbers=numbersExcluded.trim().split(" ");
for (String each:stringOfNumbers)
System.out.println(each);
but there is this when I give input like "aaa-4aaa5aaa?" the printing loop, prints
-4
5
?
why is ?
included? how can I fix this?