diff --git a/SystemTools.cxx b/SystemTools.cxx
index e9af15cfa3e80519f32126ee4b32feb340546652..c0c5baf1370684333b89ebe8b489f348a82312df 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -701,8 +701,35 @@ bool SystemTools::MakeDirectory(const kwsys_stl::string& path)
 // replace replace with with as many times as it shows up in source.
 // write the result into source.
 void SystemTools::ReplaceString(kwsys_stl::string& source,
-                                   const char* replace,
-                                   const char* with)
+                                const kwsys_stl::string& replace,
+                                const kwsys_stl::string& with)
+{
+  // do while hangs if replaceSize is 0
+  if (replace.empty())
+    {
+    return;
+    }
+
+  SystemTools::ReplaceString(source, replace.c_str(), replace.size(), with);
+}
+
+void SystemTools::ReplaceString(kwsys_stl::string& source,
+                                const char* replace,
+                                const char* with)
+{
+  // do while hangs if replaceSize is 0
+  if (!*replace)
+    {
+    return;
+    }
+
+  SystemTools::ReplaceString(source, replace, strlen(replace), with ? with : "");
+}
+
+void SystemTools::ReplaceString(kwsys_stl::string& source,
+                                const char* replace,
+                                size_t replaceSize,
+                                const kwsys_stl::string& with)
 {
   const char *src = source.c_str();
   char *searchPos = const_cast<char *>(strstr(src,replace));
@@ -714,12 +741,6 @@ void SystemTools::ReplaceString(kwsys_stl::string& source,
     }
 
   // perform replacements until done
-  size_t replaceSize = strlen(replace);
-  // do while hangs if replaceSize is 0
-  if(replaceSize == 0)
-    {
-    return;
-    }
   char *orig = strdup(src);
   char *currentPos = orig;
   searchPos = searchPos - src + orig;
diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in
index 338009e09591e862f5f7a5baa5b30012405e5689..2e45fa1ac237faa4900f836810b3d35242a6722f 100644
--- a/SystemTools.hxx.in
+++ b/SystemTools.hxx.in
@@ -102,6 +102,9 @@ public:
   static void ReplaceString(kwsys_stl::string& source,
                             const char* replace,
                             const char* with);
+  static void ReplaceString(kwsys_stl::string& source,
+                            const kwsys_stl::string& replace,
+                            const kwsys_stl::string& with);
 
   /**
    * Return a capitalized string (i.e the first letter is uppercased,
@@ -907,6 +910,14 @@ private:
     return &SystemToolsManagerInstance;
     }
 
+  /**
+   * Actual implementation of ReplaceString.
+   */
+  static void ReplaceString(kwsys_stl::string& source,
+                            const char* replace,
+                            size_t replaceSize,
+                            const kwsys_stl::string& with);
+
   /**
    * Actual implementation of FileIsFullPath.
    */