java regular expressions to extract the desired character into an array

java using regular expressions to extract the digital string, and then into the array

String regex = "\\d+";
String input = "XX交罚〔2019〕322号";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
ArrayList<String> al=new ArrayList<String>();
 
while (m.find()) { 
		            al.add(m.group(0));
		        }
System.out.println("去除重复值前");
for (int i=0;i<al.size();i++)
   {
	System.out.println(al.get(i).toString());
   }
System.err.println(al.toString());

result:

[2019, 322]

Note: https://blog.csdn.net/zhuche110/article/details/7981424

Guess you like

Origin blog.csdn.net/l_degege/article/details/90599494