cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sachin_a_pawar
Level 4

TrimStart: Removes all the occurence(s) of trim string from the original string

🙂 Function to remove occurences of certain string at start from the provided string.


prototype STRING TrimStart(STRING, STRING);

///
///Removes all occcurences of the trim string at the start of original
/// string.
///

///String to be trimmed at start.
///
// String to be removed from the start of original string.
///


function STRING TrimStart(szString, szTrim)
STRING szReturn;
begin
szReturn = szString;
while(StrFind(szReturn,szTrim) = 0)
StrSub(szReturn, szReturn, StrLength(szTrim), StrLength(szReturn));
endwhile;
return szReturn;
end;

Thanks
Sachin Pawar
Labels (1)
0 Kudos
(1) Reply
sachin_a_pawar
Level 4

🙂 Function to remove occurences of certain string from end of provided string.

prototype STRING TrimEnd(STRING, STRING);

///
///Removes all occcurences of the trim string at the end of original
/// string.
///

///String to be trimmed at end.
///
// String to be removed from the end of original string.
///


function STRING TrimEnd(szString, szTrim)
STRING szReturn;
INT ivStartIndex;
INT ivTrimLength;
begin
szReturn = szString;
ivTrimLength = StrLength(szTrim);
ivStartIndex = StrLength(szReturn) - ivTrimLength;
while(StrFindEx(szReturn,szTrim, ivStartIndex) > 0)
StrReplace(szReturn, szTrim,"",ivStartIndex);
ivStartIndex = StrLength(szReturn) - ivTrimLength;
endwhile;
return szReturn;
end;
0 Kudos