非贪婪匹配
String resStr = “\d+?”; //非贪婪匹配
public class RegExp09 {
public static void main(String[] args){
String content = "111hello123";
//String resStr = "\\d+"; //默认是贪婪匹配
String resStr = "\\d+?"; //非贪婪匹配
//1.构造模式对象Pattern
Pattern pattern = Pattern.compile(resStr);
//2.创造匹配器对象Matcher
Matcher matcher =pattern.matcher(content);
while (matcher.find()){
System.out.println("找到:"+matcher.group(0));
}
}
}