What about using $addtok, $istok and $deltok (You need to use $findtok in $deltok to find the position of the token)?
[I hate when firefox crashes because of Shift + Enter]
I've used this method before, and it works fine, as you only need one variable to store the data, and $istok won't match 'a' in "b c d e ae".

From the help file:
Quote:

$addtok(text,token,C)

Adds a token to the end of text but only if it's not already in text.

$addtok(a.b.c,d,46) returns a.b.c.d

$addtok(a.b.c.d,c,46) returns a.b.c.d

The C parameter is the ascii value of the character separating the tokens.

Note: $addtokcs() is the case-sensitive version.

$deltok(text,N-N2,C)

Deletes the Nth token from text.

$deltok(a.b.c.d,3,46) returns a.b.d

$deltok(a.b.c.d,2-3,46) returns a.d

You can specify a negative value for N.

$findtok(text,token,N,C)

Returns the position of the Nth matching token in text.

$findtok(a.b.c.d,c,1,46) returns 3

$findtok(a.b.c.d,e,1,46) returns $null

If you specify zero for N, it returns the total number of matching tokens.

Note: $findtokcs() is the case-sensitive version.

$gettok(text,N,C)

Returns the Nth token in text.

$gettok(a.b.c.d.e,3,46) returns c

$gettok(a.b.c.d.e,9,46) returns $null

You can also specify a range of tokens:

$gettok(a.b.c.d.e,2-,46) returns 2nd token onwards b.c.d.e

$gettok(a.b.c.d.e,2-4,46) returns tokens 2 through 4 b.c.d

You can specify a negative value for N.

$istok(text,token,C)

Returns $true if token exists, otherwise returns $false.

Note: $istokcs() is the case-sensitive version.