[refactor] Make Regex more simple and clear (#6141)

1. Remove Redundant character escape ‘\\}’ and ‘\\:’
2. Replace ‘{0,1}’ to ‘?’
This commit is contained in:
Arthur.Zhang
2021-07-10 10:10:41 +08:00
committed by GitHub
parent 65892cec3b
commit 814840f826
2 changed files with 2 additions and 2 deletions

View File

@ -120,7 +120,7 @@ public class ConfigBase {
// the "CONFIG_VALUE" should be replaced be env variable CONFIG_VALUE
private void replacedByEnv(Properties props) throws Exception {
// pattern to match string like "{CONFIG_VALUE}"
Pattern pattern = Pattern.compile("\\$\\{([^\\}]*)\\}");
Pattern pattern = Pattern.compile("\\$\\{([^}]*)\\}");
for (String key : props.stringPropertyNames()) {
String value = props.getProperty(key);
Matcher m = pattern.matcher(value);

View File

@ -73,7 +73,7 @@ public class TimeUtils {
+ "((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))"
+ "(\\s(((0?[0-9])|([1][0-9])|([2][0-3]))\\:([0-5]?[0-9])((\\s)|(\\:([0-5]?[0-9])))))?$");
private static final Pattern TIMEZONE_OFFSET_FORMAT_REG = Pattern.compile("^[+-]{0,1}\\d{1,2}\\:\\d{2}$");
private static final Pattern TIMEZONE_OFFSET_FORMAT_REG = Pattern.compile("^[+-]?\\d{1,2}:\\d{2}$");
public static Date MIN_DATE = null;
public static Date MAX_DATE = null;