summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2019-03-13 21:22:45 +0100
committerTor Egge <Tor.Egge@broadpark.no>2019-03-13 21:23:29 +0100
commitdf8f67e3b3a35715ecd7220e93f44a85da3f3ce3 (patch)
tree2dc5cb0ac39c65dfe3dc6bba92ce522f5c0fd9b1 /vespalib
parent820a730d7efede2a84133170639d624f7939e358 (diff)
Remove unused vespalib::Regexp::replace() method.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/regex/regex.cpp12
-rw-r--r--vespalib/src/vespa/vespalib/util/regexp.cpp19
-rw-r--r--vespalib/src/vespa/vespalib/util/regexp.h9
3 files changed, 0 insertions, 40 deletions
diff --git a/vespalib/src/tests/regex/regex.cpp b/vespalib/src/tests/regex/regex.cpp
index ac2c0241423..95d6a7e88e7 100644
--- a/vespalib/src/tests/regex/regex.cpp
+++ b/vespalib/src/tests/regex/regex.cpp
@@ -39,7 +39,6 @@ TEST("require that invalid expression fails compilation") {
Regexp bad("[unbalanced");
EXPECT_FALSE(bad.valid());
EXPECT_FALSE(bad.match("nothing"));
- EXPECT_EQUAL(vespalib::string("nothing"), bad.replace("nothing", "anything"));
}
TEST("require that * is not valid") {
@@ -47,17 +46,6 @@ TEST("require that * is not valid") {
EXPECT_FALSE(bad.valid());
}
-TEST("require that replace works") {
- Regexp rep("foo");
- EXPECT_EQUAL(vespalib::string(""), rep.replace("", "bc"));
- EXPECT_EQUAL(vespalib::string("a"), rep.replace("a", "bc"));
- EXPECT_EQUAL(vespalib::string("bc"), rep.replace("foo", "bc"));
- EXPECT_EQUAL(vespalib::string("abc"), rep.replace("afoo", "bc"));
- EXPECT_EQUAL(vespalib::string("abcd"), rep.replace("afood", "bc"));
- EXPECT_EQUAL(vespalib::string("abcdbc"), rep.replace("afoodfoo", "bc"));
- EXPECT_EQUAL(vespalib::string("abcdbcbc"), rep.replace("afoodfoofoo", "bc"));
-}
-
TEST("require that prefix detection works") {
EXPECT_EQUAL("", Regexp::get_prefix(""));
EXPECT_EQUAL("", Regexp::get_prefix("foo"));
diff --git a/vespalib/src/vespa/vespalib/util/regexp.cpp b/vespalib/src/vespa/vespalib/util/regexp.cpp
index 684ed1b8fd8..71949b82ef3 100644
--- a/vespalib/src/vespa/vespalib/util/regexp.cpp
+++ b/vespalib/src/vespa/vespalib/util/regexp.cpp
@@ -64,25 +64,6 @@ Regexp::match(vespalib::stringref s) const
return pos >= 0;
}
-vespalib::string Regexp::replace(vespalib::stringref s, vespalib::stringref replacement) const
-{
- if ( ! valid() ) { return s; }
- regex_t *preg = const_cast<regex_t *>(static_cast<const regex_t *>(_data));
- vespalib::string modified;
- int prev(0);
- for(int pos(re_search(preg, s.data(), s.size(), 0, s.size(), NULL));
- pos >=0;
- pos = re_search(preg, s.data()+prev, s.size()-prev, 0, s.size()-prev, NULL))
- {
- modified += s.substr(prev, pos);
- modified += replacement;
- int count = re_match(preg, s.data()+prev, s.size()-prev, pos, NULL);
- prev += pos + count;
- }
- modified += s.substr(prev);
- return modified;
-}
-
Regexp::~Regexp()
{
regex_t *preg = static_cast<regex_t *>(_data);
diff --git a/vespalib/src/vespa/vespalib/util/regexp.h b/vespalib/src/vespa/vespalib/util/regexp.h
index 6a97b72cdda..fe1930d2b4a 100644
--- a/vespalib/src/vespa/vespalib/util/regexp.h
+++ b/vespalib/src/vespa/vespalib/util/regexp.h
@@ -57,15 +57,6 @@ public:
bool match(vespalib::stringref s) const;
/**
- * Will replace all occurrences of this pattern is string 's' with 'replacement'.
- * If called on invalid regexp it will return an unmodified copy of the input string.
- * @param s text to search for mathes.
- * @param replacement text to replace the pattern.
- * @return modified string.
- **/
- vespalib::string replace(vespalib::stringref s, vespalib::stringref replacement) const;
-
- /**
* Look at the given regular expression and identify the prefix
* that must be present for a string to match it. Note that an
* un-anchored expression will have an empty prefix. Also note