I have list with combination of letters, digits and special characters. I need to extract the digits from string and store them in the same list.
I tried with below code
List<String> list = new LinkedList<String>();
list.add("132144, Test");
list.add("76876295, Test2");
//tried with replaceAll();
list.replaceAll(x->x.replace("[^0-9]",""));
//tried collection
Collections.replaceAll(list, "\\W+", "");
System.out.println(list);
Getting the output as [132144, Test,76876295, Test2], need output as [132144,76876295]
2of the textTest2into the result?