我不能使用for / while循环。 (因为每个都可以)
如果我有这样的列表:
List<String> list1 = new ArrayList<String> ();
包含字符/特殊字符和数字。
list1.add("123 öl jf,? .A 33 lkle 43 s se 4")
该列表中的每个数字后面都有空格。
我如何去除除数字后面的空白以外的所有内容?
输出应该像这样:
listNew = {"123 33 43", " other numbers from another string in list"}
我尝试过:
List<String> listNew= lis1.stream()
.map(s -> s.replaceAll("[^a-zA-Z0-9]+", ""))
.collect(Collectors.toList());
然后:如何计算每对数字中有多少对数字除以空格?
我搜索了几个小时,但一无所获。
我认为这是最简单或至少最清晰的方法: