我有兴趣将数字放入String
's 数组中,但无法很好地使用正则表达式和组。
代码:
package regex;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Regex {
public static void main(String[] args) {
String s = "A: 123/456 BC: 78/90 NEw: 105 E: 0 BK: 10 None: 0%";
Pattern p = Pattern.compile("(\\w+): (\\d+)");
Matcher m = p.matcher(s);
String[] as = new String[7];
as[2] = m.group(); //array list??
for (int i = 2; i < 2; i++) {
System.out.println(as[i]);
}
}
}