String.split() Not Acting on Semicolon or Space Delimiters
<p>This may be a simple question, but I have been Googling for over an hour and haven't found an answer yet.  </p>

<p>I'm trying to simply use the String.split() method with a small Android application to split an input string.  The input string will be something along the lines of: "Launch ip:192.168.1.101;port:5900".  I'm doing this in two iterations to ensure that all of the required parameters are there.  I'm first trying to do a split on spaces and semicolons to get the individual tokens sorted out.  Next, I'm trying to split on colons in order to strip off the identification tags of each piece of information.</p>

<p>So, for example, I would expect the first round of split to give me the following data from the above example string:
(1) Launch
(2) ip:192.168.1.101
(3) port:5900</p>

<p>Then the second round would give me the following:
(1) 192.168.1.101
(2) 5900</p>

<p>However, the following code that I wrote doesn't give me what's expected:</p>

<pre><code>private String[] splitString(String inputString)
{
    String[] parsedString;
    String[] orderedString = new String[SOSLauncherConstants.SOCKET_INPUT_STRING_PARSE_VALUE];

    parsedString = inputString.trim().split("; ");

    Log.i("info", "The parsed data is as follows for the initially parsed string of size " + parsedString.length + ": ");
    for (int i = 0; i &lt; parsedString.length; ++i)
    {
        Log.i("info", parsedString[i]);
    }

    for (int i = 0; i &lt; parsedString.length; ++i )
    {
        if (parsedString[i].toLowerCase().contains(SOSLauncherConstants.PARSED_LAUNCH_COMMAND_VALUE))
        {
            orderedString[SOSLauncherConstants.PARSED_COMMAND_WORD] = parsedString[i];
        }

        if (parsedString[i].toLowerCase().contains("ip"))
        {
            orderedString[SOSLauncherConstants.PARSED_IP_VALUE] = parsedString[i].split(":")[1];
        }
        else if (parsedString[i].toLowerCase().contains("port"))
        {
            orderedString[SOSLauncherConstants.PARSED_PORT_VALUE] = parsedString[i].split(":")[1];
        }
        else if (parsedString[i].toLowerCase().contains("username"))
        {
            orderedString[SOSLauncherConstants.PARSED_USERNAME_VALUE] = parsedString[i].split(":")[1];
        }
        else if (parsedString[i].toLowerCase().contains("password"))
        {
            orderedString[SOSLauncherConstants.PARSED_PASSWORD_VALUE] = parsedString[i].split(":")[1];
        }
        else if (parsedString[i].toLowerCase().contains("color"))
        {
            orderedString[SOSLauncherConstants.PARSED_COLOR_VALUE] = parsedString[i].split(":")[1];
        }
    }

    Log.i("info", "The parsed data is as follows for the second parsed string of size " + orderedString.length + ": ");
    for (int i = 0; i &lt; orderedString.length; ++i)
    {
        Log.i("info", orderedString[i]);
    }

    return orderedString;
}
</code></pre>

<p>For a result, I'm getting the following:
The parsed data is as follows for the parsed string of size 1:</p>

<p>launch ip:192.168.1.106;port:5900</p>

<p>The parsed data is as follows for the second parsed string of size 6:</p>

<p>launch ip:192.168.1.106;port:5900</p>

<p>192.168.1.106;port</p>

<p>And then, of course, it crashes because the for loop runs into a null string.</p>

<p><b>Side Note:</b>
The following snippet is from the constants class that defines all of the string indexes --</p>

<pre><code>public static final int SOCKET_INPUT_STRING_PARSE_VALUE = 6;
public static final int PARSED_COMMAND_WORD = 0;
public static final String PARSED_LAUNCH_COMMAND_VALUE = "launch";
public static final int PARSED_IP_VALUE = 1;
public static final int PARSED_PORT_VALUE = 2;
public static final int PARSED_USERNAME_VALUE = 3;
public static final int PARSED_PASSWORD_VALUE = 4;
public static final int PARSED_COLOR_VALUE = 5;
</code></pre>

<p>I looked into needing a possible escape (by inserting a \\ before the semicolon) on the semicolon delimiter, and even tried using it, but that didn't work.  The odd part is that neither the space nor the semicolon function as a delimiter, yet the colon works on the second time around.  Does anybody have any ideas what would cause this?</p>

<p>Thanks for your time!</p>

<p>EDIT:  I should also add that I'm receiving the string over a WiFi socket connection.  I don't think this should make a difference, but I'd like you to have all of the information that you need.</p>
