Things I hate about VBScript - part 36,431

LTjake on 2003-08-26T19:59:36

Split.

Please, someone, give me a good reason why Split( str, "" ) returns str?! I want to be able to do something like:

my @chars = split(//, $str);

But noooooooooooooo.....


How about alternation?

cwest on 2003-08-26T21:25:15

It has been a very long time since I tried my hand at VBScript, I'm still healing. How about: Split( str, "|" )?

string splitting...

neuroball on 2003-08-27T02:51:27

... with an empty expression string (would produce an array of all characters in the string in perl) will NOT produce an array but return the string as if cut with space as the expression.

You might want to do this by hand... using a foreach loop and Left or something abominable to get each character of the string.

VBs code for split uses InStr and InStrRev (sp?) searching for the pattern and Mid to cut out the string.

I once parsed HTML brackets (a long time ago) for equality of said bracket numbers... yet I wrote my own split which was much faster.

Sorry to hear about your pain.
/neuroball/

Re:string splitting...

pjm on 2003-08-27T03:57:06

Am I missing something here?

~ % perl -e 'print join("*",split "","something here"),"\n"'
s*o*m*e*t*h*i*n*g* *h*e*r*e

Or if you prefer...

~ % perl -e 'print join("*",split //,"something here"),"\n"'
s*o*m*e*t*h*i*n*g* *h*e*r*e

Re:string splitting...

LTjake on 2003-08-27T11:13:14

To make an array of chars i did this:

Dim arrInput
ReDim arrInput( Len( strInput ) - 1 )

For intTemp = 1 To Len( strInput )
    arrInput( intTemp - 1 ) = Mid( strInput, intTemp, 1 )
Next

Sucky, i know, but atleast doing:

strInput = Join( arrInput, "" )

works to get the string back! :)