1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 22:36:38 +02:00

core: improve the string_replace_regex function (add reference char, change syntax for match refs)

The reference char is now an argument for the function.
The references are now $0 .. $99 and $+ was added (last match, with
highest number).
The syntax to replace a match with one char is now: $.cN or $.c+
(for example: "$.*3").
This commit is contained in:
Sebastien Helleu
2014-02-09 15:14:07 +01:00
parent f666a356d7
commit 7c0d9fe850
6 changed files with 102 additions and 43 deletions
+2 -1
View File
@@ -114,7 +114,8 @@ trigger_callback_replace_regex (struct t_trigger *trigger,
value = weechat_string_replace_regex (ptr_value,
trigger->regex[i].regex,
trigger->regex[i].replace_eval);
trigger->regex[i].replace_eval,
'$');
if (!value)
continue;
+4 -4
View File
@@ -618,12 +618,12 @@ trigger_command_init ()
" replace password with '*' in /oper command (in command line and "
"command history):\n"
" /trigger add oper modifier input_text_display;history_add "
"\"\" \"==^(/oper +\\S+ +)(.*)==\\1\\*2\"\n"
"\"\" \"==^(/oper +\\S+ +)(.*)==$1$.*2\"\n"
" add text attributes in *bold*, _underline_ and /italic/:\n"
" /trigger add effects modifier weechat_print \"\" "
"\"==\\*(\\S+)\\*==*${color:bold}\\1${color:-bold}*== "
"==_(\\S+)_==_${color:underline}\\1${color:-underline}_== "
"==/(\\S+)/==/${color:italic}\\1${color:-italic}/\"\n"
"\"==\\*(\\S+)\\*==*${color:bold}$1${color:-bold}*== "
"==_(\\S+)_==_${color:underline}$1${color:-underline}_== "
"==/(\\S+)/==/${color:italic}$1${color:-italic}/\"\n"
" silently save config each hour:\n"
" /trigger add cfgsave timer 3600000;0;0 \"\" \"\" \"/mute /save\""),
"list|listfull"
+3 -1
View File
@@ -221,7 +221,9 @@ trigger_config_create_option (const char *trigger_name, int index_option,
"many regex can be separated by a space, for example: "
"\"/regex1/replace1/var1 /regex2/replace2/var2\"; the "
"separator \"/\" can be replaced by any char (one or more "
"identical chars), except '\\' and parentheses"),
"identical chars), except '\\' and parentheses; matching "
"groups can be used in replace: $0 to $99, $+ for last "
"match and $.cN to replace all chars of group N by char c"),
NULL, 0, 0, value, NULL, 0,
NULL, NULL, &trigger_config_change_regex, NULL, NULL, NULL);
break;