On 8 Aug 2004, at 2:38, tedd wrote: > Hi gang: > Before I launch myself into doing something that everyone has already > done, I thought I would check first. > I need a way to parse out segments of a text container -- such as > deleting text starting at some delimiter string and ending at another > delimiter string. For example, if I had text which contained: > aaaa aaaaa aaaaaa aaaaaa \++ aaaaaa bbbbbb ccccccc ddddddd eeeeeeee _/ > aaaaa aaaaaa aaaaa > and then parse out everything between the "\++" and "_/" to leave: > aaaa aaaaa aaaaaa aaaaaa aaaaa aaaaaa aaaaa > Anyone have a simple function to do that? I was going to keep these offlist because they're not very elegant. But, what the hell !... I'll do anything for a cheap plug :) Bernie local mode local fn RemoveBlockFromString$(s as Str255, s1 as Str255, s2 as Str255) dim as short startPos, endPos '~'1 do startPos = instr(1, s, s1) long if startPos endPos = instr(startPos + len(s1), s, s2) if endPos then s = left$(s, startPos - 1) + mid$(s, endPos + len(s2)) end if until (startPos == 0) or (endPos == 0) end fn = s local mode local fn RemoveBlockFromContainer(@cPtr as ptr, s1 as Str255, s2 as Str255) dim as Handle cH dim as long startPos, endPos, size '~'1 cH = [cPtr] do size = fn GetHandleSize(cH) startPos = fn munger(cH, 0, @s1[1], s1[0], _nil, _nil) long if (startPos >= 0) endPos = fn munger(cH, startPos + s1[0], @s2[1], s2[0], _nil, _nil) long if (endPos >= 0) endPos += s2[0] BlockMove([cH] + endPos, [cH] + startPos, size - endPos) size -= (endPos - startPos) SetHandleSize(cH, size) end if end if until (startPos < 0) or (endPos < 0) end fn dim as container gC dim as Str255 s, s1, s2 window 1 s1 = "\++" s2 = "_/" s = "TWM (The Window Maker) is \++probably_/the best OS X FutureBasic GUI builder in the world" gC = "\++Don't _/go here: <http://homepage.ntlworld.com/bernie.w/twmad.htm>" print s print gC print print fn RemoveBlockFromString$(s, s1, s2) fn RemoveBlockFromContainer(gC, s1, s2) print gC do HandleEvents until 0