Index: /branches/rel10_ifa/psLib/src/sys/psString.c
===================================================================
--- /branches/rel10_ifa/psLib/src/sys/psString.c	(revision 6566)
+++ /branches/rel10_ifa/psLib/src/sys/psString.c	(revision 6567)
@@ -13,6 +13,6 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-02-01 20:40:56 $
+ *  @version $Revision: 1.24.4.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-03-09 19:37:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -214,2 +214,43 @@
 }
 
+// given the input string, search for all copies of the key, and replace with the replacement value
+// the input string may be freed if not needed
+char *psStringSubstitute (char *input, char *replace, char *key)
+{
+
+    char *p;
+
+    if (key == NULL)
+        return input;
+    if (strlen(key) == 0)
+        return input;
+
+    while (true) {
+        p = strstr (input, key);
+        if (p == NULL)
+            return input;
+
+        // we have input = xxxkeyxxx
+        // we want output = xxxreplacexxx
+
+        // this is safe since we will subtract strlen(key) elements from input
+        char *output = psAlloc(strlen(input) + strlen(replace) + 1);
+        int Nc = p - input;
+
+        // copy the first segement into 'output'
+        strncpy (output, input, Nc);
+
+        // copy the key replacement to the start of the key
+
+        strcpy (&output[Nc], replace);
+        Nc += strlen (replace);
+
+        // copy the remainder to the end of the replacement
+        strcpy (&output[Nc], p + strlen(key));
+
+        psFree (input);
+        input = output;
+    }
+    return input;
+}
+
Index: /branches/rel10_ifa/psLib/src/sys/psString.h
===================================================================
--- /branches/rel10_ifa/psLib/src/sys/psString.h	(revision 6566)
+++ /branches/rel10_ifa/psLib/src/sys/psString.h	(revision 6567)
@@ -14,6 +14,6 @@
  *  @author David Robbins, MHPCC
  *
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-02-01 20:40:56 $
+ *  @version $Revision: 1.18.4.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-03-09 19:37:28 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -103,4 +103,12 @@
 );
 
+// given the input string, search for all copies of the key, and replace with the replacement value
+// the input string may be freed if not needed
+char *psStringSubstitute (
+    char *input,    ///< input string to be modified
+    char *replace,    ///< replacement value
+    char *key    ///< string to be replaced in input
+);
+
 /** @} */// Doxygen - End of SystemGroup Functions
 
