diff options
| author | Torsten Keil <github@torsten-keil.net> | 2012-02-22 21:00:30 +0100 |
|---|---|---|
| committer | Torsten Keil <github@torsten-keil.net> | 2012-02-22 21:00:30 +0100 |
| commit | c1418a6ef61c6700f0850fdc5c10f73d96afa522 (patch) | |
| tree | 475448d2b6805c2f40c15dcbef48c00f5e1b85eb /main/src | |
| parent | a5b5204d53489e0d257ffd5fcb1a41eae9e47835 (diff) | |
| download | cgeo-c1418a6ef61c6700f0850fdc5c10f73d96afa522.zip cgeo-c1418a6ef61c6700f0850fdc5c10f73d96afa522.tar.gz cgeo-c1418a6ef61c6700f0850fdc5c10f73d96afa522.tar.bz2 | |
Improved pattern to respect dot as thousands separator too
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/cgeo/geocaching/GCConstants.java | 4 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 4 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/utils/LogTemplateProvider.java | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/main/src/cgeo/geocaching/GCConstants.java b/main/src/cgeo/geocaching/GCConstants.java index af717ee..b1519fd 100644 --- a/main/src/cgeo/geocaching/GCConstants.java +++ b/main/src/cgeo/geocaching/GCConstants.java @@ -56,8 +56,8 @@ public final class GCConstants { // Info box top-right public static final Pattern PATTERN_LOGIN_NAME = Pattern.compile("\"SignedInProfileLink\">([^<]+)</a>"); public static final Pattern PATTERN_MEMBER_STATUS = Pattern.compile("<span id=\"ctl00_litPMLevel\" style=\"display: block;\">([^<]+)</span>"); - /** Use replaceAll(",","") on the resulting string before converting to an int */ - public static final Pattern PATTERN_CACHES_FOUND = Pattern.compile("title=\"Caches Found\"[\\s\\w=\"/\\.]*/>\\s*([\\d,]+)"); + /** Use replaceAll("[,\\.]","") on the resulting string before converting to an int */ + public static final Pattern PATTERN_CACHES_FOUND = Pattern.compile("title=\"Caches Found\"[\\s\\w=\"/\\.]*/>\\s*([\\d,\\.]+)"); public static final Pattern PATTERN_AVATAR_IMAGE_PROFILE_PAGE = Pattern.compile("<img src=\"(http://img.geocaching.com/user/avatar/[0-9a-f-]+\\.jpg)\"[^>]*\\salt=\"Avatar\""); public static final Pattern PATTERN_LOGIN_NAME_LOGIN_PAGE = Pattern.compile("<span class=\"Success\">You are logged in as[^<]*<strong[^>]*>([^<]+)</strong>[^<]*</span>"); public static final Pattern PATTERN_CUSTOMDATE = Pattern.compile("<option selected=\"selected\" value=\"([ /Mdy-]+)\">"); diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index c88739c..bc37422 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -364,7 +364,7 @@ public class cgBase { if (isActualLoginStatus()) { setActualUserName(BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???")); setActualMemberStatus(BaseUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???")); - setActualCachesFound(Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll(",", ""))); + setActualCachesFound(Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll("[,\\.]", ""))); return true; } @@ -1416,7 +1416,7 @@ public class cgBase { Settings.setMemberStatus(BaseUtils.getMatch(profile, GCConstants.PATTERN_MEMBER_STATUS, true, null)); - setActualCachesFound(Integer.parseInt(BaseUtils.getMatch(profile, GCConstants.PATTERN_CACHES_FOUND, true, "-1").replaceAll(",", ""))); + setActualCachesFound(Integer.parseInt(BaseUtils.getMatch(profile, GCConstants.PATTERN_CACHES_FOUND, true, "-1").replaceAll("[,\\.]", ""))); final String avatarURL = BaseUtils.getMatch(profile, GCConstants.PATTERN_AVATAR_IMAGE_PROFILE_PAGE, false, null); if (null != avatarURL) { diff --git a/main/src/cgeo/geocaching/utils/LogTemplateProvider.java b/main/src/cgeo/geocaching/utils/LogTemplateProvider.java index 775f5cc..b55bd3b 100644 --- a/main/src/cgeo/geocaching/utils/LogTemplateProvider.java +++ b/main/src/cgeo/geocaching/utils/LogTemplateProvider.java @@ -127,6 +127,6 @@ public class LogTemplateProvider { return -1; } - return Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "-1").replaceAll(",", "")); + return Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "-1").replaceAll("[,\\.]", "")); } } |
