Reputation: 733
I have a project which receives a delimited string through SMS. I am tasked to split the string by colon (:
) using the Split
function. My SMS server receives the messages and my script processes it.
Sample code:
dim a
a = split(string,delimiter)
dim value
value = a(1)
Sample input (SMS message): abc:def ghi:jkl
Now when I split it, I was expecting value
to return only def
, but I get defghi
instead. Why?
Upvotes: 1
Views: 4502
Reputation: 576
Your output is correct, split()
creates an array of substrings which are determined by the delimiter provided.
The substring "def ghi"
is due to whitespace being used to separate the characters instead of a colon.
If you don't want the whitespace you can use split again with no given delimiter, " "
is the default used when one isn't provided.
e.g. split(value1)
You could also try checking the received string for spaces and replacing any found with colons and then proceed as normal.
Upvotes: 4