Просмотр исходного кода

Remove redundant character escape of regexp

sunyj 8 лет назад
Родитель
Сommit
0d08437277

+ 2 - 2
src/main/java/com/uas/report/crystal2jasper/CrystalToJasper.java

@@ -367,7 +367,7 @@ public class CrystalToJasper {
 		Set<String> result = new HashSet<>();
 		while ((line = bufferedReader.readLine()) != null) {
 			// 格式为$F{PD_TOTAL}
-			Pattern pattern = Pattern.compile("\\$F\\{([^\\$]*)\\}");
+			Pattern pattern = Pattern.compile("\\$F\\{([^$]+?)\\}");
 			Matcher matcher = pattern.matcher(line);
 			while (matcher.find()) {
 				result.add(matcher.group(1).toUpperCase());
@@ -423,7 +423,7 @@ public class CrystalToJasper {
 		Set<String> result = new HashSet<>();
 		while ((line = bufferedReader.readLine()) != null) {
 			// 格式为$V{PD_TOTAL}
-			Pattern pattern = Pattern.compile("\\$V\\{([^\\$]*)\\}");
+			Pattern pattern = Pattern.compile("\\$V\\{([^$]+?)\\}");
 			Matcher matcher = pattern.matcher(line);
 			while (matcher.find()) {
 				result.add(matcher.group(1));

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

@@ -432,7 +432,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());
@@ -753,7 +753,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();