Click to See Complete Forum and Search --> : parsing text string based from array values


havey
10-11-2006, 10:38 PM
Hi have a a long string and can get the value after the 17th character of > like so:
myString = "<asdf>asd<dd>asd<asdd>asdf.....

myArray = split(myString,">")
myNewVal = left(myArray(17),instr(myArray(17),"<")-1)
'response.write(myNewVal)

but now i have many > to get the value after, so i'm trying to do things effeciently and this is what i have so far, my error is subscript out of range, any thought on this:

DIM myString, myArray, myNewVal, x

myString = "<asdf>asd<dd>asd<asdd>asdf.....

Dim CharArray(30)

CharArray(0) = 17
CharArray(1) = 19
CharArray(2) = 21
....
CharArray(30) = 81

For x = LBound(CharArray()) To UBound(CharArray())

myArray = split(myString,">")
myNewVal = left(myArray(CharArray(x)),instr(CharArray(x),"<")-1)
response.write(myNewVal)

Next

jvanamali
10-12-2006, 03:10 PM
Use Dim CharArray(31) instead of Dim CharArray(30)

or CharArray(0) to CharArray(29)