ReplStr

This function does a search-replace for arbitrary-length substrings in a string. See examples program at rbHash. code format="vbnet" function replstr$(ret$,hit$,src$,rept) 'find hit$ in ret$, replace with src$, do it rept times, 'do all possible if rept = 0. 'return modified string. rpx = 0 hitpos = INSTR(ret$,hit$) while hitpos > 0 rpx = rpx + 1 front$ = LEFT$(ret$,hitpos -1 ) back$ = MID$(ret$,hitpos + LEN(hit$)) ret$ = front$ + src$ + back$ nextpos = hitpos + LEN(src$) hitpos = INSTR(ret$,hit$,nextpos) IF rpx = rept then hitpos = 0 wend replstr$ = ret$ end function code (Return to User Functions for more code snippets.)