62,612
社区成员
发帖
与我相关
我的任务
分享
public static void main(String args[]) {
String regex = "(?<=“)([^“”]*|[^“”]*“.*”[^“”]*)(?=”)";//你给的例子里双引号是全角,如果是半角则用\"替换“和”;
Pattern p = Pattern.compile(regex);
String str = "xx“aa“bb”cc”yy ";
//str = "xx“aa”bb“cc”yy";
Matcher m = p.matcher(str);
while(m.find()) {
System.out.println(m.group());
}
}
\
String str = "xx“aa“bb”cc”yy ";
System.out.println(str.replaceAll("xx(.*)yy","$1"));
public static void main(String args[]) {
String regex = "(?<=“).*(?=”)";//你给的例子里双引号是全角,如果是半角刚regex = "(?<=\").*(?=\")";
Pattern p = Pattern.compile(regex);
String str = "xx“aa“bb”cc”yy ";
Matcher m = p.matcher(str);
while(m.find()) {
System.out.println(m.group());
}
}