(Unicode C) StringBuilder ReplaceBetween
Demonstrates the ReplaceBetween method.
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkStringBuilderW sb;
int numReplacements;
sb = CkStringBuilderW_Create();
CkStringBuilderW_Append(sb,L"<company><industry>Software</industry><name>Chilkat Software</name><abc>Abc Software</abc><name>Xyz Software</name></company>");
// The ReplaceBetween method restricts the replacements to only
// the parts that occur between two delimiter strings.
// For example:
numReplacements = CkStringBuilderW_ReplaceBetween(sb,L"<name>",L"</name>",L"Software",L"Technology");
// The number of replacements should be 2.
wprintf(L"numReplacements = %d\n",numReplacements);
// The sb now contains:
// <company><industry>Software</industry><name>Chilkat Technology</name><abc>Abc Software</abc><name>Xyz Technology</name></company>
wprintf(L"%s\n",CkStringBuilderW_getAsString(sb));
CkStringBuilderW_Dispose(sb);
}
|