View Full Version : Split() - no delimeter
12-17-2003, 08:22 PM
well, i know u can split like "a,b,c" into "a","b","c" using "," as the delimeter, but is there any way to split "abc" into "a","b","c"?
12-17-2003, 11:34 PM
I don't think so, you'd prolly need to write a function to do that. Would it always be a single character that you'd want to seperate out? If so, it would be pretty easy to write a loop to do that.
12-18-2003, 06:34 AM
12-18-2003, 07:32 AM
var str = "abc";
var jsArrStr = str.split("").toString(); //returns "a,b,c"
vbArr = split(jsArrStr,",")
for i = 0 to ubound(vbArr)
response.write "item" & i & "=" & vbArr(i) & "<br>"
You cannot assign a js array directly into a vbscript array so string representation of the js array is needed, thus the .toString() bit. Although it is not required since if you do a vbscript split of a js array, the specified js array is implicitly turned into a string. But it's better to explicitly turn it into a string.
12-20-2003, 11:54 AM
Why bother with all that? Simply loop through the strip character-by-character like OracleGuy suggested it's by far the easiest, probably a little quicker, and doesn't require ASP to load a second script interpreter.
Untested code follows:
Dim ArrayOutput(), StringLen, N
StringLen = Len(StringInput)
ReDim ArrayOutput(StringLen - 1)
For N = 0 To StringLen - 1
ArrayOutput(N) = Mid(StringInput, N + 1, 1)
SplitIntoChars = ArrayOutput
12-22-2003, 09:23 PM
who said my first script interpreter is not JScript?
12-24-2003, 08:41 PM
Originally posted by Roelf
who said my first script interpreter is not JScript? Nobody did! But ghell (and glenngv) seem to be using VBScript!
12-24-2003, 10:09 PM
i couldn't tell that from ghell's post :p
but enough with the jokin'around
your solution should work fine
12-25-2003, 02:44 AM
Roelf, how could you not tell he was using VBScript from that post?
Your psychic internet abilities are slipping, man. :p
By the way, Happy Holidays, everyone!!!
12-29-2003, 05:42 PM
sorry i didnt answer sooner, i was in mediera :(
merry xmas whammy, happy new year too :D
anyway, i am just trying to do a sorta hashing algorithm type thingie... its not anything to do with hashing tho, its just sorta encrypting a password and unencrypting it afterwards so that my m8s "steal their coockie for my site and take their password from it" program will not work because what he will get out of the cookie will be jibberish, i could maby do it with replaces now i think about it, if i put a loop or just plain 26 or 52 lines of replaces
it cant really go client side because of the security and it cant redirect or anything because it has to run in the background, ill try the replaces though, now i have had so much time to think about it :p
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.