glib r7762 - in trunk: . glib
- From: matthiasc svn gnome org
- To: svn-commits-list gnome org
- Subject: glib r7762 - in trunk: . glib
- Date: Sat, 3 Jan 2009 05:10:33 +0000 (UTC)
Author: matthiasc
Date: Sat Jan 3 05:10:33 2009
New Revision: 7762
URL: http://svn.gnome.org/viewvc/glib?rev=7762&view=rev
Log:
Add docs
Modified:
trunk/ChangeLog
trunk/glib/gregex.c
Modified: trunk/glib/gregex.c
==============================================================================
--- trunk/glib/gregex.c (original)
+++ trunk/glib/gregex.c Sat Jan 3 05:10:33 2009
@@ -2530,6 +2530,45 @@
* string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
* that begins with any kind of lookbehind assertion, such as "\b".
*
+ * The following example uses g_regex_replace_eval() to replace multiple
+ * strings at once:
+ * |[
+ * static gboolean
+ * eval_cb (const GMatchInfo *info,
+ * GString *res,
+ * gpointer data)
+ * {
+ * gchar *match;
+ * gchar *r;
+ *
+ * match = g_match_info_fetch (info, 0);
+ * r = g_hash_table_lookup ((GHashTable *)data, match);
+ * g_string_append (res, r);
+ * g_free (match);
+ *
+ * return FALSE;
+ * }
+ *
+ * /* ... */
+ *
+ * GRegex *reg;
+ * GHashTable *h;
+ * gchar *res;
+ *
+ * h = g_hash_table_new (g_str_hash, g_str_equal);
+ *
+ * g_hash_table_insert (h, "1", "ONE");
+ * g_hash_table_insert (h, "2", "TWO");
+ * g_hash_table_insert (h, "3", "THREE");
+ * g_hash_table_insert (h, "4", "FOUR");
+ *
+ * reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
+ * res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
+ * g_hash_table_destroy (h);
+ *
+ * /* ... */
+ * ]|
+ *
* Returns: a newly allocated string containing the replacements
*
* Since: 2.14
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]