空格也要的话 (?<=")[A-Z ]+(?=")
不要空格就 (?<=")[A-Z]+
[Java] 纯文本查看 复制代码 public static void main(String[] args) {
/** 无空格 */
// final String regex = "(?<=\")[A-Z]+";
/** 有空格 */
final String regex = "(?<=\")[A-Z ]+(?=\")";
final String string = "\"DATE \"\"YEARS \"\"DAY \"\"MONTH \"\"YEAR \"\"FLPR \"\"FLPRH \"\"FLPT \"\"FLPTH \"\"FMWIN \"";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println(matcher.group());
}
} |