62,623
社区成员
发帖
与我相关
我的任务
分享regex="A.*?B"
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test {
public static void main(String[] args) {
String input = "A12sdfc B Bscf ddA dscd12 B ";
Pattern p = Pattern.compile("A.*?B");
Matcher m = p.matcher(input);
while (m.find()) {
System.out.println(m.group());
}
}
}
/*
A12sdfc B
A dscd12 B
*/