diff options
| author | Bananeweizen <Bananeweizen@gmx.de> | 2012-10-02 08:15:07 +0200 |
|---|---|---|
| committer | Bananeweizen <Bananeweizen@gmx.de> | 2012-10-02 08:15:07 +0200 |
| commit | 1f8a42c0b5d4897e23f4b523cb73fa95545a4b19 (patch) | |
| tree | 442adc3e8e5c0cb972c34b5f6a348059999ab600 | |
| parent | ecfa8a40228087df7bf1f69bc479447a191f6083 (diff) | |
| download | cgeo-1f8a42c0b5d4897e23f4b523cb73fa95545a4b19.zip cgeo-1f8a42c0b5d4897e23f4b523cb73fa95545a4b19.tar.gz cgeo-1f8a42c0b5d4897e23f4b523cb73fa95545a4b19.tar.bz2 | |
fix #2034: GPX eport from c:geo can not be imported to c:geo
| -rw-r--r-- | main/src/cgeo/geocaching/utils/BaseUtils.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/utils/BaseUtils.java b/main/src/cgeo/geocaching/utils/BaseUtils.java index d468fc9..2f34e4e 100644 --- a/main/src/cgeo/geocaching/utils/BaseUtils.java +++ b/main/src/cgeo/geocaching/utils/BaseUtils.java @@ -11,6 +11,8 @@ import java.util.regex.Pattern; */ public final class BaseUtils { + private static final Pattern PATTERN_REMOVE_NONPRINTABLE = Pattern.compile("\\p{Cntrl}"); + /** * Searches for the pattern p in the data. If the pattern is not found defaultValue is returned * @@ -26,7 +28,7 @@ public final class BaseUtils { * Value to return if the pattern is not found * @param last * Find the last occurring value - * @return defaultValue or the n-th group if the pattern matches (trimed if wanted) + * @return defaultValue or the n-th group if the pattern matches (trimmed if wanted) */ public static String getMatch(final String data, final Pattern p, final boolean trim, final int group, final String defaultValue, final boolean last) { if (data != null) { @@ -38,6 +40,9 @@ public final class BaseUtils { result = matcher.group(group); } if (null != result) { + Matcher remover = PATTERN_REMOVE_NONPRINTABLE.matcher(result); + result = remover.replaceAll(""); + return trim ? new String(result).trim() : new String(result); // Java copies the whole page String, when matching with regular expressions // later this would block the garbage collector, as we only need tiny parts of the page |
