debian man page for strsub

Query: strsub

OS: debian

Section: 3pub

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

STRSUB(3pub)						       C Programmer's Manual						      STRSUB(3pub)

NAME
strsub - substitute first occurence of pattern with another string
SYNOPSIS
#include <publib.h> char *strsub(char *str, const char *pat, const char *sub);
DESCRIPTION
strsub finds the first occurence of the pattern pat in the string str (using a method similar to strstr(3), i.e., no regular expressions), and replaces it with sub. If pat does not occur in str, no substitution is made. Of course, if sub is an empty string, the pattern is deleted from the string.
RETURN VALUE
strsub returns a pointer to the first character after the substitution, or NULL if no substitution was made.
EXAMPLE
To substitute up to two occurences of "foo" with "bar" in a line, one might do the following. p = strsub(line, "foo", "bar"); if (p != NULL) strsub(line, "foo", "bar");
SEE ALSO
publib(3), strstr(3), strgsub(3)
AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi) Publib C Programmer's Manual STRSUB(3pub)
Related Man Pages
strltrim(3pub) - debian
strsplit(3pub) - debian
strsub(3pub) - debian
strvars(3pub) - debian
strgsub(3pub) - debian
Similar Topics in the Unix Linux Community
Sed and replacing one occurence of pattern
Only one particular occurence needs to be substituted !!!
Search file for pattern2 starting from occurence of pattern1
Substitution/Addition
sed command to substitute contents from external file