(PureBasic) StringBuilder ReplaceBetween
Demonstrates the ReplaceBetween method.
IncludeFile "CkStringBuilder.pb"
Procedure ChilkatExample()
sb.i = CkStringBuilder::ckCreate()
If sb.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkStringBuilder::ckAppend(sb,"<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.i = CkStringBuilder::ckReplaceBetween(sb,"<name>","</name>","Software","Technology")
; The number of replacements should be 2.
Debug "numReplacements = " + Str(numReplacements)
; The sb now contains:
; <company><industry>Software</industry><name>Chilkat Technology</name><abc>Abc Software</abc><name>Xyz Technology</name></company>
Debug CkStringBuilder::ckGetAsString(sb)
CkStringBuilder::ckDispose(sb)
ProcedureReturn
EndProcedure
|