正则表达式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
* @author devin
* @version 1.0.2
* @date 2021-02-16 23:23
*/
public class Zhenze {
// 待匹配字符串

public static void main(String[] args) {
String str = "湖北省武汉市1573rr4562";
Pattern p = Pattern.compile("[1-9]+");
Matcher m = p.matcher(str);
while(m.find()){
System.out.println(m.group());
}
}

}
Donate comment here