我正在尝试拆分一个字符串,例如:“@WWP2-@POLUXDATAWWP3-TTTTTW@K826”以在执行代码段时提取@WWP2-@POLUXDATAWWP3-TTTTTW 和 826 个字符串:
String expression = "@WWP2-@POLUXDATAWWP3-TTTTTW@K826";
StringTokenizer tokenizer = new StringTokenizer(expression, "@K");
if (tokenizer.countTokens() > 0) {
while (tokenizer.hasMoreTokens()) {
System.out.println(tokenizer.nextToken());
}
}
同时期望结果是
WWP2-POLUXDATAWWP3-TTTTTW
826
我越来越:
WWP2-
POLUXDATAWWP3-TTTTTW
826
关于如何获得确切的两个字符串的任何想法?