STrings MAniPulation in a textbox

Split is just a function that separates your string by a given delimiter and put it into an array. You could do that with regular expressions yourself but split is a ready to use regExp function.
You are trying to extract a specific part of that string. Since that string is a message send through a certain protocol it has some sort of separator that separates the chunks. If you call the split method on your message (string) giving it the delimiter (in your case the ';') the chunks of your message are separated and copied into an array. Each chunk has it's own position thus making indexing pretty easy --> first chunk = first position = index 0. The messgae itself is not touched by the split method but the delimiter (',') is removed. Two delimiters represent an empty chunk. Since a part of the message could be optinoal (e.g. routing information) the poistioning of the chunks would change. Sending empty chunks keeps the positions of chunks in the right order.
If you know the position of your chunk in the message you know it's index in the resulting array of the split method (position-1).

If your string (message) isn't touched by another call it should just work fine the way Vca told you.
 
Back
Top