]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add string.replace method, patch by Ali Sabil
authorJürg Billeter <j@bitron.ch>
Mon, 24 Nov 2008 15:13:41 +0000 (15:13 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Mon, 24 Nov 2008 15:13:41 +0000 (15:13 +0000)
2008-11-24  Jürg Billeter  <j@bitron.ch>

* vapi/glib-2.0.vapi:

Add string.replace method, patch by Ali Sabil

svn path=/trunk/; revision=2062

ChangeLog
vapi/glib-2.0.vapi

index 17b509c153a769645736d575c14dabe3f286bdd7..23daf9f8aed52a4df7a21f30d59ebd0efecf44c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-24  Jürg Billeter  <j@bitron.ch>
+
+       * vapi/glib-2.0.vapi:
+
+       Add string.replace method, patch by Ali Sabil
+
 2008-11-24  Jürg Billeter  <j@bitron.ch>
 
        * ccode/valaccodefunctioncall.vala:
index ddc1251e7507c8e60844f8214c23c12e0edabc58..1c7dbb4fdc01893a8aa8ad5c5db7cd84e8f93124 100644 (file)
@@ -796,6 +796,15 @@ public class string {
        /* internal method */
        public string substring (long offset, long len);
 
+       public string replace (string old, string replacement) {
+               try {
+                       var regex = new GLib.Regex (GLib.Regex.escape_string (old));
+                       return regex.replace_literal (this, -1, 0, replacement);
+               } catch (GLib.RegexError e) {
+                       GLib.assert_not_reached ();
+               }
+       }
+
        public long length {
                get { return this.len (); }
        }