aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/str.cpp7
-rw-r--r--common/str.h6
-rw-r--r--test/common/str.h3
3 files changed, 16 insertions, 0 deletions
diff --git a/common/str.cpp b/common/str.cpp
index faf84d722f..ae3a965c70 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -751,6 +751,13 @@ bool matchString(const char *str, const char *pat, bool ignoreCase, bool pathMod
return true;
break;
+ case '#':
+ if (!isDigit(*str))
+ return false;
+ pat++;
+ str++;
+ break;
+
default:
if ((!ignoreCase && *pat != *str) ||
(ignoreCase && tolower(*pat) != tolower(*str))) {
diff --git a/common/str.h b/common/str.h
index a30dae3513..1b41c481c7 100644
--- a/common/str.h
+++ b/common/str.h
@@ -158,6 +158,7 @@ public:
* Token meaning:
* "*": any character, any amount of times.
* "?": any character, only once.
+ * "#": any decimal digit, only once.
*
* Example strings/patterns:
* String: monkey.s01 Pattern: monkey.s?? => true
@@ -165,6 +166,8 @@ public:
* String: monkey.s99 Pattern: monkey.s?1 => false
* String: monkey.s101 Pattern: monkey.s* => true
* String: monkey.s99 Pattern: monkey.s*1 => false
+ * String: monkey.s01 Pattern: monkey.s## => true
+ * String: monkey.s01 Pattern: monkey.### => false
*
* @param pat Glob pattern.
* @param ignoreCase Whether to ignore the case when doing pattern match
@@ -330,6 +333,7 @@ String normalizePath(const String &path, const char sep);
* Token meaning:
* "*": any character, any amount of times.
* "?": any character, only once.
+ * "#": any decimal digit, only once.
*
* Example strings/patterns:
* String: monkey.s01 Pattern: monkey.s?? => true
@@ -337,6 +341,8 @@ String normalizePath(const String &path, const char sep);
* String: monkey.s99 Pattern: monkey.s?1 => false
* String: monkey.s101 Pattern: monkey.s* => true
* String: monkey.s99 Pattern: monkey.s*1 => false
+ * String: monkey.s01 Pattern: monkey.s## => true
+ * String: monkey.s01 Pattern: monkey.### => false
*
* @param str Text to be matched against the given pattern.
* @param pat Glob pattern.
diff --git a/test/common/str.h b/test/common/str.h
index adc6a099e4..3ab5d828c1 100644
--- a/test/common/str.h
+++ b/test/common/str.h
@@ -332,6 +332,9 @@ class StringTestSuite : public CxxTest::TestSuite
TS_ASSERT(!Common::matchString("monkey.s99", "monkey.s*1"));
TS_ASSERT(Common::matchString("monkey.s101", "monkey.s*1"));
+ TS_ASSERT(Common::matchString("monkey.s01", "monkey.s##"));
+ TS_ASSERT(!Common::matchString("monkey.s01", "monkey.###"));
+
TS_ASSERT(!Common::String("").matchString("*_"));
TS_ASSERT(Common::String("a").matchString("a***"));
}