1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 16:23:14 +02:00

api: add "${re:repl_index}" to get the index of replacement in function string_eval_expression

This commit is contained in:
Sébastien Helleu
2021-08-29 10:40:52 +02:00
parent 009a2889e3
commit 2de272ee6c
9 changed files with 88 additions and 33 deletions
+12
View File
@@ -989,6 +989,18 @@ TEST(CoreEval, EvalReplaceRegex)
hashtable_set (options, "regex_replace", "${re:z}");
WEE_CHECK_EVAL("", "abc");
/* use replace index: add number before each item */
hashtable_remove (pointers, "regex");
hashtable_set (options, "regex", "[^,]+");
hashtable_set (options, "regex_replace", "${re:repl_index}.${re:0}");
WEE_CHECK_EVAL("1.item1,2.item2,3.item3", "item1,item2,item3");
/* use replace index: replace each letter by its position */
hashtable_remove (pointers, "regex");
hashtable_set (options, "regex", ".");
hashtable_set (options, "regex_replace", "${re:repl_index}");
WEE_CHECK_EVAL("1234", "test");
hashtable_free (pointers);
hashtable_free (extra_vars);
hashtable_free (options);