我有一个文本字符串“ 9926 9928 9951 9953 0 30 57 12 40 54 30”
我对以 99 为前缀的 4 位数字感兴趣。其他数字是多余的。
期望的输出:
9926
9928
9951
9953
我的代码:
String str = " 9926 9928 9951 9953 0 30 57 12 40 54 30";
Iterable<String> result = Splitter.onPattern("99").fixedLength(4).split(str);
实际输出:
992
6 99
28 9
951
9953
0 3
0 57
12
40 5
4 30