|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sflstr.h"
char *
searchreplace (
char *strbuf,
char *strtofnd,
char *strtoins)
A case insensitive search and replace. Searches for all occurances of a string, and replaces it with another string. Returns a pointer to head of the buffer. Submitted by Scott Beasley jscottb@infoave.com
{
char *offset, *strbase;
ASSERT (strbuf);
ASSERT (strtofnd);
ASSERT (strtoins);
offset = strbase = (char *)NULL;
while (*strbuf)
{
offset = stricstr (!offset ? strbuf : strbase, strtofnd);
if (offset)
{
strbase = (offset + strlen (strtoins));
strcpy (offset, (offset + strlen (strtofnd)));
memmove (offset + strlen (strtoins),
offset, strlen (offset) + 1);
memcpy (offset, strtoins, strlen (strtoins));
}
else
break;
}
return strbuf;
}
| | << | < | > | >> |
|