Przeglądaj źródła

正则改为非贪婪

sunyj 8 lat temu
rodzic
commit
544dc24734

+ 2 - 2
src/main/java/com/uas/report/service/impl/PrintServiceImpl.java

@@ -423,7 +423,7 @@ public class PrintServiceImpl implements PrintService {
 		String xml = FileUtils.readAsString(new File(jrxmlFilePath));
 		Set<String> result = new HashSet<>();
 		// 格式为$F{PD_TOTAL}
-		Pattern pattern = Pattern.compile("\\$F\\{([^\\$]*)\\}");
+		Pattern pattern = Pattern.compile("\\$F\\{([^\\$]*?)\\}");
 		Matcher matcher = pattern.matcher(xml);
 		while (matcher.find()) {
 			result.add(matcher.group(1).toUpperCase());
@@ -728,7 +728,7 @@ public class PrintServiceImpl implements PrintService {
 				throw new IllegalArgumentException("未传入动态参数");
 			}
 			JSONObject parameters = JSONObject.parseObject(otherParameters);
-			Pattern pattern = Pattern.compile("\\$P\\{([^\\$]*)\\}");
+			Pattern pattern = Pattern.compile("\\$P\\{([^\\$]*?)\\}");
 			Matcher matcher = pattern.matcher(sql);
 			while (matcher.find()) {
 				String match = matcher.group();