Rechercher une page de manuel
strgsub.3pub
Langue: en
Version: C Programmer's Manual (debian - 07/07/09)
Section: 3 (Bibliothèques de fonctions)
NAME
strgsub - substitute all occurences of pattern with another stringSYNOPSIS
#include <publib.h> int strgsub(char *str, const char *pat, const char *sub, size_t max);
DESCRIPTION
strgsub finds all occurences of the pattern pat in the string str (using a method similar to strstr(3) to find the occurrences, i.e., no regular expressions), and replaces each with sub. If pat does not occur in str, no substitution is made. The size (including the terminating '\0') of the string after the substitutions may be at most max chars. If it would be larger, no substitutions are made.Of course, if sub is an empty string, the occurences of the pattern are deleted from the string.
RETURN VALUE
strgsub returns the number of substitutions made, or -1 if the result would not have fit into max chars.EXAMPLE
To substitute every "foo" with "bar" in a line, one might do the following.strgsub(line, "foo", "bar", strlen(line)+1);
SEE ALSO
publib(3), strstr(3), strsub(3)AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi)Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre