Procedure.s TrimString(s1$,s2$)
Protected fs
while left(s1$,len(s2$))=s2$ or right(s1$,len(s2$))=s2$
if left(s1$,len(s2$))=s2$
s1$=right(s1$,len(s1$)-len(s2$))
endif
if right(s1$,len(s2$))=s2$
s1$=left(s1$,len(s1$)-len(s2$))
endif
wend
ProcedureReturn s1$
EndProcedure
; cw() <- is short for consolewrite()
s1$ ="dog cat monkey dog horse dog" ;<- dog on both ends
s2$ ="dog"
s1$ =TrimString(s1$,s2$)
cw(s1$) ;>" cat monkey dog horse " ;<- 0x20 on both ends
s2$ ="cat"
s1$ =TrimString(s1$,s2$)
cw(s1$) ;>" cat monkey dog horse " ;<- 0x20 on both ends
; Input string: "dog cat monkey dog horse dog"
; Strings that need to be trimmed from each end: { "dog", "cat" }
; Note: he says: 'Strings that need to be trimmed from each end'
; not that the Input string should be trimmed of 0x20
; that's probably obvious... but i thought i read a comment that
; the Input string should be trimmed of 0x20 (whitespaces)
; language PureBasic...