java 怎么利用正则表达式从给定的字符串中取出匹配规则字符串

2025-03-20 20:10:13
推荐回答(1个)
回答1:

String regex="\\d";
String input="123abc4k";
Pattern p=Pattern.compile(regex);
Matcher m=p.matcher(input);
while(m.find()){
System.out.println(m.group());//输出字符串中的数字
}

类似这样写,主要在于正则表达式