Skip to main content
GameDev.net gamedev.net
🔒 Locked

using delimers

Started by smacker Dec 9, 2005 at 1:00 PM 1 replies 500+ views
Original Post
smacker
smacker
here is my problem let me show you the code first

if(strMessage.IndexOf("<EOF>") > -1)
      {
		string delimStr = "<EOF>";
		char [] delimchar = delimStr.ToCharArray();
		mypacket = strMessage.Split(delimchar);
seems easy strMessage is my packet and im looking for "" that is placed at the end of every packet, then I split the packet. mypacket is a string array so I add the split strMessage to mypacket. the problem is mypacket.lenght is 6. mypacket[0] = the data I need mypacket[1] - mypacket[5] = a empty string im guessing its placing 1 empty string per each character in my delimStr how can I remove these before placing the needed data into the mypacket array
graveyard filla
graveyard filla
you post is a little vague so it is difficult to give this a straight answer.

are you looking for a slick way to do this automatically?

if i were you, id just do something like

ArrayList mypacket = new ArrayList(strMessage.Split(delimchar));

mypacket.RemoveRange(1,mypacket.Count-1)


theres probably a slick way to do this, but your post is a little vague so it becomes a guessing game.

something like this might be what you're looking for (avoid the split completely and just grab everything up untill the EOF).

mypacket = strMessage.Substring(0,strMessage.IndexOf("")
FTA, my 2D futuristic action MMORPG

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.