|
Previous Top Next |
Prototype: | (STRING pBegin, STRING pEnd, STRING pSearchString, STRING pInsertString, BYTE pHandling, <Long pBeginPos>, <Long pEndBeginPos>, BYTE pCaseSensitive=FALSE),STRING |
pBegin | The 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. |
pEnd | The 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. |
pSearchString | The string to search in. |
pInsertString | The string to insert into pSearchString |
pHandling | How the insert is handled. It can be ITStIns:Prefix, ITStIns:Append or ITStIns:Replace. |
pBeginPos | Optionally specify where to start searching in pSearchString to find the beginning position |
pEndBeginPos | Optionally specify where to start searching in pSearchString to find the beginning of the end position. |
pCaseSensitive | Optionally specify if the search should be case sensitive. Defaults to false (i.e. NOT case sensitive - all comparisons are done using UPPER() |
Returns | Returns 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: