ExtractStr

This function finds and returns a substring marked by opening and closing delimters, like the tags in HTML or markup code in word processing text files. See program example at rbHash. code format="vbnet" function extractstr$(ret$,opentag$,endtag$) ' extract string between opentag and endtag ' works on copy of passed string to keep from ' modifying the original string.

openpos = 0 endpos = 0 openpos = INSTR(ret$,opentag$) IF openpos > 0 then openpos = openpos + LEN(opentag$) endpos = INSTR(ret$,endtag$,openpos) IF endpos > 0 then ret$ = MID$(ret$,openpos,endpos - openpos) END IF ELSE ret$ = "" END IF extractstr$ = ret$ end function code

(Return to User Functions for more snippets.)