From: Jürg Billeter Date: Mon, 24 Nov 2008 15:13:41 +0000 (+0000) Subject: Add string.replace method, patch by Ali Sabil X-Git-Tag: VALA_0_5_2~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11efbc3d4ea1a50e7dec80c53bd33cdc7011d58b;p=thirdparty%2Fvala.git Add string.replace method, patch by Ali Sabil 2008-11-24 Jürg Billeter * vapi/glib-2.0.vapi: Add string.replace method, patch by Ali Sabil svn path=/trunk/; revision=2062 --- diff --git a/ChangeLog b/ChangeLog index 17b509c15..23daf9f8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-11-24 Jürg Billeter + + * vapi/glib-2.0.vapi: + + Add string.replace method, patch by Ali Sabil + 2008-11-24 Jürg Billeter * ccode/valaccodefunctioncall.vala: diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index ddc1251e7..1c7dbb4fd 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -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 (); } }