GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
STRSUB(3) C Programmer's Manual STRSUB(3)

strsub - substitute first occurence of pattern with another string

#include <publib.h>
char *strsub(char *str, const char *pat, const char *sub);

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.

strsub returns a pointer to the first character after the substitution, or NULL if no substitution was made.

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");

publib(3), strstr(3), strgsub(3)

Lars Wirzenius (lars.wirzenius@helsinki.fi)
C Programmer's Manual Publib

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.