[英]how to split string contains numbers in java?
I have String like this: "LODIXAL COMP 15" 我有这样的字符串:“LODIXAL COMP 15”
How can i split it to "LODIXAL COMP" and "15" ? 我怎么能把它分成“LODIXAL COMP”和“15”?
String a = "LODIXAL COMP 15";
String[] result = {"LODIXAL COMP" , "15"}
Use this positive lookahead based regex: 使用这个正面的前瞻性正则表达式:
a.split(" (?=\\d+)");
TESTING: 测试:
System.out.println(Arrays.toString(a.split(" (?=\\d+)")));
OUTPUT: OUTPUT:
[LODIXAL COMP, 15]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.