aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-12-27 18:05:55 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-12-27 18:05:55 -0800
commitf40ef905b1db1aadabbd4496331755fb984d88c5 (patch)
treec0694d68cae720e35287c60cbfd0bbf73c88d4bb /src
parent1ca42bd2d0e999d4fb0141ee183dabe37d3a40f9 (diff)
downloadtraccar-server-f40ef905b1db1aadabbd4496331755fb984d88c5.tar.gz
traccar-server-f40ef905b1db1aadabbd4496331755fb984d88c5.tar.bz2
traccar-server-f40ef905b1db1aadabbd4496331755fb984d88c5.zip
Simplify regex
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/helper/PatternBuilder.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/helper/PatternBuilder.java b/src/main/java/org/traccar/helper/PatternBuilder.java
index 5c4638189..3197a8149 100644
--- a/src/main/java/org/traccar/helper/PatternBuilder.java
+++ b/src/main/java/org/traccar/helper/PatternBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ public class PatternBuilder {
}
public PatternBuilder text(String s) {
- fragments.add(s.replaceAll("([\\\\\\.\\[\\{\\(\\)\\*\\+\\?\\^\\$\\|])", "\\\\$1"));
+ fragments.add(s.replaceAll("([\\\\.\\[{()*+?^$|])", "\\\\$1"));
return this;
}
@@ -48,7 +48,7 @@ public class PatternBuilder {
s = s.replace("dddd", "d{4}").replace("ddd", "d{3}").replace("dd", "d{2}");
s = s.replace("xxxx", "x{4}").replace("xxx", "x{3}").replace("xx", "x{2}");
- s = s.replace("d", "\\d").replace("x", "[0-9a-fA-F]").replaceAll("([\\.])", "\\\\$1");
+ s = s.replace("d", "\\d").replace("x", "[0-9a-fA-F]").replaceAll("([.])", "\\\\$1");
s = s.replaceAll("\\|$", "\\\\|").replaceAll("^\\|", "\\\\|"); // special case for delimiter
fragments.add(s);