It's quite a pain to do in vbscript actually, so the best suggestion would be to use a language with decent string operations, dynamic list support, and slicing, Python will do :) But it would go somewhere along those lines (not so sure about syntax):
dim strText
strText = "Friend1|Friend2|Friend3|Friend4|Friend5"
function removeName(strName)
dim arrName, found, ind, i, arrFinal()
arrName = split(strText, "|")
found = vbFalse
ind = 0
for each i in arrName do
if i = strName then
found = vbTrue
end if
if not found then
Redim Preserve arrFinal(ind)
arrFinal(ind) = i
ind = ind + 1
end if
next
removeName = join(arrFinal, "|")
end function
I give no guarantees that this will work at all, but don't have time to test it. The basic idea is to use a static array filled with actual names (using split()) and a dynamic array, which is gradually expanded to include all names from the first array except the one you want to exclude. Once the dynamic array is full, and we've reached the end of the static one, we join the dynamic array back into a "|" separated string and return it. But as vbscript sucks really badly for these sorts of operations, you might have to tweak it to get it to work. |