www.icetips.com  Icetips Utilities Documentation 10/29/2015    

String Class:  SetStringBetween

Previous  Top  Next  


Prototype: (STRING pBegin, STRING pEnd, STRING pSearchString, STRING pInsertString, BYTE pHandling, <Long pBeginPos>, <Long pEndBeginPos>, BYTE pCaseSensitive=FALSE),STRING

 

pBeginThe string to search for to mark the beginning of the new string.  The new string starts in the character position after the pBegin is found.
pEndThe string to search for to mark the end of the new string.  The new string ends in the character position before the pEnd is found.
pSearchStringThe string to search in.
pInsertStringThe string to insert into pSearchString
pHandlingHow the insert is handled.  It can be ITStIns:Prefix, ITStIns:Append or ITStIns:Replace.
pBeginPosOptionally specify where to start searching in pSearchString to find the beginning position
pEndBeginPosOptionally specify where to start searching in pSearchString to find the beginning of the end position.
pCaseSensitiveOptionally specify if the search should be case sensitive.  Defaults to false (i.e. NOT case sensitive - all comparisons are done using UPPER()

 

ReturnsReturns the updated string with the pInsertString inserted if the pBegin and pEnd were found.

 

This method inserts a substring into a string given a start string and end string.  Note that this method does NOT do multiple inserts, it will only insert the string in one place, the first place it finds between the pBegin and pEnd strings.  The SetStringEnd and SetStringFound can be checked to see if there are more occurrences to replace and where they begin.  If SetStringFound is 0 then there are no more pBegin/pEnd pairs in the resulting string.

 

Example:

PROGRAM

INCLUDE('ITUtilityClass.inc'),ONCE

MAP

END

S    CString(1000)

I    Long

ITS  ITStringClass

CODE

S = '<a>stuff</a>'

S = ITS.SetStringBetween('<a>','</a>',S,'test',ITStIns:Append)

! String is now: "<a>stufftest</a>"

 

S = '<a>stuff</a>'

S = ITS.SetStringBetween('<a>','</a>',S,'test',ITStIns:Prefix)

! String is now: "<a>teststuff</a>"

 

S = '<a>stuff</a>'

S = ITS.SetStringBetween('<a>','</a>',S,'test',ITStIns:Replace)

! String is now: "<a>test</a>"

 

 

See also:

GetStringBetween

 



Direct link to this page: http://www.icetips.com/manuals/utilities/setstringbetween_stringclass.htm