doc: add function string_replace_regex in plugin API reference
parent
0bfacb5592
commit
05eda016ec
|
@ -1214,6 +1214,60 @@ highlight = weechat.string_has_highlight_regex(string, regex)
|
|||
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
|
||||
----
|
||||
|
||||
==== weechat_string_replace_regex
|
||||
|
||||
_WeeChat ≥ 0.4.4._
|
||||
|
||||
Replace text in a string using a regular expression and replacement text.
|
||||
|
||||
Prototype:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
char *weechat_string_replace_regex (const char *string, void *regex,
|
||||
const char *replace, const char reference_char);
|
||||
----
|
||||
|
||||
Arguments:
|
||||
|
||||
* 'string': string
|
||||
* 'regex': pointer to a regular expression ('regex_t' structure) compiled with
|
||||
WeeChat function <<_weechat_string_regcomp,weechat_string_regcomp>> or regcomp
|
||||
(see `man regcomp`)
|
||||
* 'replace': replacement text, where following references are allowed:
|
||||
** `$0` to `$99`: match 0 to 99 in regular expression (0 is the whole match,
|
||||
1 to 99 are groups captured between parentheses)
|
||||
** `$+`: the last match (with highest number)
|
||||
** `$.*N`: match `N` (can be `+` or `0` to `99`), with all chars replaced by `*`
|
||||
(the `*` char can be any char between space (32) and `~` (126))
|
||||
* 'reference_char': the char used for reference to match (commonly '$')
|
||||
|
||||
Return value:
|
||||
|
||||
* string with text replaced, NULL if problem (must be freed by calling "free"
|
||||
after use)
|
||||
|
||||
C example:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
regex_t my_regex;
|
||||
char *string;
|
||||
if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
|
||||
REG_EXTENDED) == 0)
|
||||
{
|
||||
string = weechat_string_replace_regex ("date: 2014-02-14", &my_regex,
|
||||
"$3/$2/$1", '$');
|
||||
/* string == "date: 14/02/2014" */
|
||||
if (string)
|
||||
free (string);
|
||||
regfree (&my_regex);
|
||||
}
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
This function is not available in scripting API.
|
||||
|
||||
==== weechat_string_split
|
||||
|
||||
Split a string according to one or more delimiter(s).
|
||||
|
@ -1244,7 +1298,7 @@ Return value:
|
|||
* array of strings, NULL if problem (must be freed by calling
|
||||
<<_weechat_string_free_split,weechat_string_free_split>> after use)
|
||||
|
||||
C examples:
|
||||
C example:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
|
|
|
@ -1230,6 +1230,65 @@ highlight = weechat.string_has_highlight_regex(string, regex)
|
|||
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
|
||||
----
|
||||
|
||||
==== weechat_string_replace_regex
|
||||
|
||||
_WeeChat ≥ 0.4.4._
|
||||
|
||||
Remplacer du texte dans une chaîne en utilisant une expression régulière et du
|
||||
texte de remplacement.
|
||||
|
||||
Prototype :
|
||||
|
||||
[source,C]
|
||||
----
|
||||
char *weechat_string_replace_regex (const char *string, void *regex,
|
||||
const char *replace, const char reference_char);
|
||||
----
|
||||
|
||||
Paramètres :
|
||||
|
||||
* 'string' : chaîne
|
||||
* 'regex' : pointeur vers une expression régulière (structure 'regex_t')
|
||||
compilée avec la fonction WeeChat
|
||||
<<_weechat_string_regcomp,weechat_string_regcomp>> ou regcomp (voir
|
||||
`man regcomp`)
|
||||
* 'replace' : texte de remplacement, où les références suivantes sont
|
||||
autorisées :
|
||||
** `$0` à `$99` : correspondance 0 à 99 dans l'expression régulière (0 est la
|
||||
correspondance entière, 1 à 99 sont les groupes capturés entre parenthèses)
|
||||
** `$+` : la dernière correspondance (avec le numéro le plus élevé)
|
||||
** `$.*N` : correspondance `N` (peut être `+` ou de `0` à `99`), avec tous les
|
||||
caractères remplacés par `*` (le caractère `*` peut être n'importe quel
|
||||
caractère entre l'espace (32) et `~` (126))
|
||||
* 'reference_char' : le caractère utilisé pour les références aux
|
||||
correspondances (en général '$')
|
||||
|
||||
Valeur de retour :
|
||||
|
||||
* chaîne avec le texte remplacé, NULL en cas de problème (doit être supprimée
|
||||
par un appel à "free" après utilisation)
|
||||
|
||||
Exemple en C :
|
||||
|
||||
[source,C]
|
||||
----
|
||||
regex_t my_regex;
|
||||
char *string;
|
||||
if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
|
||||
REG_EXTENDED) == 0)
|
||||
{
|
||||
string = weechat_string_replace_regex ("date: 2014-02-14", &my_regex,
|
||||
"$3/$2/$1", '$');
|
||||
/* string == "date: 14/02/2014" */
|
||||
if (string)
|
||||
free (string);
|
||||
regfree (&my_regex);
|
||||
}
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
Cette fonction n'est pas disponible dans l'API script.
|
||||
|
||||
==== weechat_string_split
|
||||
|
||||
Découper une chaîne à l'aide de délimiteur(s).
|
||||
|
|
|
@ -1245,6 +1245,63 @@ highlight = weechat.string_has_highlight_regex(string, regex)
|
|||
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
|
||||
----
|
||||
|
||||
==== weechat_string_replace_regex
|
||||
|
||||
_WeeChat ≥ 0.4.4._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Replace text in a string using a regular expression and replacement text.
|
||||
|
||||
Prototipo:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
char *weechat_string_replace_regex (const char *string, void *regex,
|
||||
const char *replace, const char reference_char);
|
||||
----
|
||||
|
||||
Argomenti:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* 'string': string
|
||||
* 'regex': pointer to a regular expression ('regex_t' structure) compiled with
|
||||
WeeChat function <<_weechat_string_regcomp,weechat_string_regcomp>> or regcomp
|
||||
(see `man regcomp`)
|
||||
* 'replace': replacement text, where following references are allowed:
|
||||
** `$0` to `$99`: match 0 to 99 in regular expression (0 is the whole match,
|
||||
1 to 99 are groups captured between parentheses)
|
||||
** `$+`: the last match (with highest number)
|
||||
** `$.*N`: match `N` (can be `+` or `0` to `99`), with all chars replaced by `*`
|
||||
(the `*` char can be any char between space (32) and `~` (126))
|
||||
* 'reference_char': the char used for reference to match (commonly '$')
|
||||
|
||||
Valore restituito:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* string with text replaced, NULL if problem (must be freed by calling "free"
|
||||
after use)
|
||||
|
||||
Esempio in C:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
regex_t my_regex;
|
||||
char *string;
|
||||
if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
|
||||
REG_EXTENDED) == 0)
|
||||
{
|
||||
string = weechat_string_replace_regex ("date: 2014-02-14", &my_regex,
|
||||
"$3/$2/$1", '$');
|
||||
/* string == "date: 14/02/2014" */
|
||||
if (string)
|
||||
free (string);
|
||||
regfree (&my_regex);
|
||||
}
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
Questa funzione non è disponibile nelle API per lo scripting.
|
||||
|
||||
==== weechat_string_split
|
||||
|
||||
Divide una stringa in base a uno o più delimitatori.
|
||||
|
@ -1301,6 +1358,9 @@ argv = weechat_string_split ("abc de fghi", " ", 1, 0, &argc);
|
|||
weechat_string_free_split (argv);
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
Questa funzione non è disponibile nelle API per lo scripting.
|
||||
|
||||
==== weechat_string_free_split
|
||||
|
||||
Libera la memoria usata per la divisione di una stringa.
|
||||
|
|
|
@ -1212,6 +1212,63 @@ highlight = weechat.string_has_highlight_regex(string, regex)
|
|||
highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
|
||||
----
|
||||
|
||||
==== weechat_string_replace_regex
|
||||
|
||||
_WeeChat バージョン 0.4.4 以上で利用可。_
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Replace text in a string using a regular expression and replacement text.
|
||||
|
||||
プロトタイプ:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
char *weechat_string_replace_regex (const char *string, void *regex,
|
||||
const char *replace, const char reference_char);
|
||||
----
|
||||
|
||||
引数:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* 'string': string
|
||||
* 'regex': pointer to a regular expression ('regex_t' structure) compiled with
|
||||
WeeChat function <<_weechat_string_regcomp,weechat_string_regcomp>> or regcomp
|
||||
(see `man regcomp`)
|
||||
* 'replace': replacement text, where following references are allowed:
|
||||
** `$0` to `$99`: match 0 to 99 in regular expression (0 is the whole match,
|
||||
1 to 99 are groups captured between parentheses)
|
||||
** `$+`: the last match (with highest number)
|
||||
** `$.*N`: match `N` (can be `+` or `0` to `99`), with all chars replaced by `*`
|
||||
(the `*` char can be any char between space (32) and `~` (126))
|
||||
* 'reference_char': the char used for reference to match (commonly '$')
|
||||
|
||||
戻り値:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* string with text replaced, NULL if problem (must be freed by calling "free"
|
||||
after use)
|
||||
|
||||
C 言語での使用例:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
regex_t my_regex;
|
||||
char *string;
|
||||
if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
|
||||
REG_EXTENDED) == 0)
|
||||
{
|
||||
string = weechat_string_replace_regex ("date: 2014-02-14", &my_regex,
|
||||
"$3/$2/$1", '$');
|
||||
/* string == "date: 14/02/2014" */
|
||||
if (string)
|
||||
free (string);
|
||||
regfree (&my_regex);
|
||||
}
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
スクリプト API ではこの関数を利用できません。
|
||||
|
||||
==== weechat_string_split
|
||||
|
||||
1 つ以上の区切り文字に従って文字列を分割。
|
||||
|
|
Loading…
Reference in New Issue