tags:

views:

39

answers:

1

I use the split function of in VBScript to split the string. Below is the code am using.

Dim inputText
DIM resultArray 

inputText = "abc; def; ""xyz;123"""
resultArray = Split(inputText, "; ")

For i = 0 To UBound(resultArray)
    resultArray(i) = Replace(resultArray(i), """", "")          
    resultArray(i) = Replace(resultArray(i), ";", "")
    IF i = UBound(resultArray) THEN
        Response.Write resultArray(i)
    ELSE
        Response.Write resultArray(i) & "; "
    END IF
Next

If i remove the space after ; in split function it will also split "xyz:123" which i don't want to be.

Either i gave space after ; in split function (Line # 4) or not it shouldn't split the "xyz:123" which comes in double quotes.

Any suggestion how i can achieve this ?

Thanks in advance.

+3  A: 

That suspiciously looks like a csv-file. You could try using ADO for this. Microsoft has a fairly extensive (and very useful) article on this: http://msdn.microsoft.com/en-us/library/ms974559.aspx

Since they describe exactly your problem, I think that just might be your solution. :)

Rob
I think this sounds like a perfect answer to the question at hand. Great eye in seeing the similarities of CSV as I was looking in a direction 180 degrees opposite.
Jeff