Index: glib/gstrfuncs.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gstrfuncs.c,v
retrieving revision 1.109
diff -u -r1.109 gstrfuncs.c
--- glib/gstrfuncs.c	27 Jul 2004 06:02:15 -0000	1.109
+++ glib/gstrfuncs.c	19 Aug 2004 09:07:45 -0000
@@ -2696,3 +2696,44 @@
   
   return msgval;
 }
+
+
+
+/**
+ * g_strreplace
+ * @string: a string
+ * @search: search string
+ * @replacement: replacement string
+ * 
+ * Replaces all occurences of @search in a new copy of @string 
+ *   by @replacement.
+ * 
+ * Return value: A newly allocated string, where all @search 
+ *   strings are replaced by the @replacement string.
+ *
+ * Since: 2.6
+ **/
+gchar *
+g_strreplace (const gchar *string,
+              const gchar *search,
+              const gchar *replacement)
+{
+  gchar *str, **arr;
+
+  g_return_val_if_fail (string != NULL, NULL);
+  g_return_val_if_fail (search != NULL, NULL);
+
+  if (replacement == NULL)
+    replacement = "";
+
+  arr = g_strsplit (string, search, -1);
+  if (arr != NULL && arr[0] != NULL)
+    str = g_strjoinv (replacement, arr);
+  else
+    str = g_strdup (string);
+
+  g_strfreev (arr);
+	
+  return str;
+}
+
Index: glib/gstrfuncs.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gstrfuncs.h,v
retrieving revision 1.21
diff -u -r1.21 gstrfuncs.h
--- glib/gstrfuncs.h	28 Jan 2004 00:37:45 -0000	1.21
+++ glib/gstrfuncs.h	19 Aug 2004 09:07:45 -0000
@@ -116,6 +116,10 @@
 					gssize        haystack_len,
 					const gchar  *needle);
 
+gchar *               g_strreplace     (const gchar  *string,
+                                        const gchar  *search,
+                                        const gchar  *replacement);
+
 gboolean              g_str_has_suffix (const gchar  *str,
 					const gchar  *suffix);
 gboolean              g_str_has_prefix (const gchar  *str,
Index: tests/strfunc-test.c
===================================================================
RCS file: /cvs/gnome/glib/tests/strfunc-test.c,v
retrieving revision 1.21
diff -u -r1.21 strfunc-test.c
--- tests/strfunc-test.c	28 Jan 2004 00:37:44 -0000	1.21
+++ tests/strfunc-test.c	19 Aug 2004 09:07:46 -0000
@@ -541,6 +541,10 @@
 
 #undef S
 
+  TEST (NULL, strcmp(g_strreplace("abcdefgcdf", "cd", "ab"), "ababefgabf") == 0);
+  TEST (NULL, strcmp(g_strreplace("abcdefg", "p", "___"), "abcdefg") == 0);
+  TEST (NULL, strcmp(g_strreplace("x 'yz \"''\"'", "'", "''"), "x ''yz \"''''\"''") == 0);
+  
   {
     gchar buf[5];
     
