user878: I am sending a list of servo positions via the serial connection to the arduino in the following format
1:90&2:80&3:180

Which would be parsed as:
servoId : Position & servoId : Position & servoId : Position
How would I split these values up, and convert them to an integer?

user42035: char str[] = "1:90&2:80&3:180";     // test sample serial input from servo
int servoId;
int position;

char* p = str;
while (sscanf(p, "%d:%d", &servoId, &position) == 2)
{
    // process servoId, position here
    //
    while (*p && *p++ != '&');   // to next id/pos pair
}


user43756: jfpoilpret provided great answer for parsing serial command on Arduino. However Attiny85 doesn't have bidirectional serial - SoftwareSerial has to be used. This is how you port same code for Attiny85
#include <SoftwareSerial.h>

// Calculate based on max input size expected for one command
#define INPUT_SIZE 30

// Initialize SoftwareSerial
SoftwareSerial mySerial(3, 4); // RX=PB3, TX=PB4

// Parameter for receiving Serial command (add 1 for final 0)
char input[INPUT_SIZE + 1];

void setup() {
  mySerial.begin(9600);
}

void loop() {
  // We need this counter to simulate Serial.readBytes which SoftwareSerial lacks
  int key = 0;

  // Start receiving command from Serial
  while (mySerial.available()) {
    delay(3);  // Delay to allow buffer to fill, code gets unstable on Attiny85 without this for some reason
    // Don't read more characters than defined
    if (key < INPUT_SIZE && mySerial.available()) {
      input[key] = mySerial.read();
      key += 1;
    }
  }

  if (key > 0) {
    // Add the final 0 to end the C string
    input[key] = 0;

    // Read each command pair
    char* command = strtok(input, "&");
    while (command != 0)
    {
      // Split the command in two values
      char* separator = strchr(command, ':');
      if (separator != 0)
      {
        // Actually split the string in 2: replace ':' with 0
        *separator = 0;
        int servoId = atoi(command);
        ++separator;
        int position = atoi(separator);
      }
      // Find the next command in input string
      command = strtok(0, "&");
    }
  }
}

Attiny85 schematics for pin numbers

Sketch compiles into:
Sketch uses 2244 bytes (27%) of program storage space. Maximum is 8192 bytes.
Global variables use 161 bytes (31%) of dynamic memory, leaving 351 bytes for local variables. Maximum is 512 bytes.

So there is plenty of space and memory for the rest of code

user7788: String getValue(String data, char separator, int index)
{
    int maxIndex = data.length() - 1;
    int j = 0;
    String chunkVal = "";

    for (int i = 0; i <= maxIndex && j <= index; i++)
    {
        chunkVal.concat(data[i]);

        if (data[i] == separator)
        {
            j++;

            if (j > index)
            {
                chunkVal.trim();
                return chunkVal;
            }

            chunkVal = "";
        }
        else if ((i == maxIndex) && (j < index)) {
            chunkVal = "";
            return chunkVal;
        }
    }   
}


user7899: See example at:
https://github.com/BenTommyE/Arduino_getStringPartByNr
// splitting a string and return the part nr index split by separator
String getStringPartByNr(String data, char separator, int index) {
    int stringData = 0;        //variable to count data part nr 
    String dataPart = "";      //variable to hole the return text

    for(int i = 0; i<data.length()-1; i++) {    //Walk through the text one letter at a time
        if(data[i]==separator) {
            //Count the number of times separator character appears in the text
            stringData++;
        } else if(stringData==index) {
            //get the text when separator is the rignt one
            dataPart.concat(data[i]);
        } else if(stringData>index) {
            //return text and stop if the next separator appears - to save CPU-time
            return dataPart;
            break;
        }
    }
    //return text if this is the last part
    return dataPart;
}


user13432: Simplest solution is to use sscanf().
  int id1, id2, id3;
  int pos1, pos2, pos3;
  char* buf = "1:90&2:80&3:180";
  int n = sscanf(buf, "%d:%d&%d:%d&%d:%d", &id1, &pos1, &id2, &pos2, &id3, &pos3);
  Serial.print(F("n="));
  Serial.println(n);
  Serial.print(F("id1="));
  Serial.print(id1);
  Serial.print(F(", pos1="));
  Serial.println(pos1);
  Serial.print(F("id2="));
  Serial.print(id2);
  Serial.print(F(", pos2="));
  Serial.println(pos2);
  Serial.print(F("id3="));
  Serial.print(id3);
  Serial.print(F(", pos3="));
  Serial.println(pos3);

This give the following output:
n=6
id1=1, pos1=90
id2=2, pos2=80
id3=3, pos3=180

Cheers!

user27: You can use Stream.readStringUntil(terminator) passing a different terminator for each part.
On each part you then call String.toInt

user666: You could do something like the following, but please take into account several things:
If you use readStringUntil(), it will wait until it receives the character or timeouts. Thus, with your current string, the last position will last a little longer, as it has to wait. You can add a trailing & to avoid this timout. You can easily check this behavior in your monitor, try to send the string with and without the extra & and you will see such timeout delay.
You actually do not need the servo index, you can just send your string of positions, and get the servo index by the value position in the string, something like: 90&80&180&. If you use the servo index, maybe you want to check it (convert to int, and then match the loop index i) to ensure that nothing went wrong with your message.
You have to check that the returning string from readStringUntil is not empty. If the function timeouts, you didn't receive enough data, and thus any attempt to extract your int values will produce strange results.
void setup() {
    Serial.begin(9600);
}

void loop() {
    for(int i=1; i<=3; i++) {
        String servo = Serial.readStringUntil(':');
        if(servo != ""){
            //here you could check the servo number
            String pos = Serial.readStringUntil('&');
            int int_pos=pos.toInt();
            Serial.println("Pos");
            Serial.println(int_pos);
        }
    }
}


user1115: This function can be used to separate a string into pieces based on what the separating character is.  
String xval = getValue(myString, ':', 0);
String yval = getValue(myString, ':', 1);

Serial.println("Y:" + yval);
Serial.print("X:" + xval);

Convert String to int
int xvalue = xvalue.toInt(xval);
int yvalue = yvalue.toInt(yval);

This Chunk of code takes a string and separates it based on a given character and     returns
The item between the separating character  
String getValue(String data, char separator, int index)
{
    int found = 0;
    int strIndex[] = { 0, -1 };
    int maxIndex = data.length() - 1;

    for (int i = 0; i <= maxIndex && found <= index; i++) {
        if (data.charAt(i) == separator || i == maxIndex) {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i+1 : i;
        }
    }
    return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}


user84: Contrarily to other answers, I'd rather stay away from String for the following reasons:

dynamic memory usage (that may quickly lead to heap fragmentation and memory exhaustion)
quite slow due to construction/destruction/assignment operators

In an embedded environment like Arduino (even for a Mega that has more SRAM), I'd rather use standard C functions:

strchr(): search for a character in a C string (i.e. char *)
strtok(): splits a C string into substrings, based on a separator character 
atoi(): converts a C string to an int

That would lead to the following code sample:
// Calculate based on max input size expected for one command
#define INPUT_SIZE 30
...

// Get next command from Serial (add 1 for final 0)
char input[INPUT_SIZE + 1];
byte size = Serial.readBytes(input, INPUT_SIZE);
// Add the final 0 to end the C string
input[size] = 0;

// Read each command pair 
char* command = strtok(input, "&");
while (command != 0)
{
    // Split the command in two values
    char* separator = strchr(command, ':');
    if (separator != 0)
    {
        // Actually split the string in 2: replace ':' with 0
        *separator = 0;
        int servoId = atoi(command);
        ++separator;
        int position = atoi(separator);

        // Do something with servoId and position
    }
    // Find the next command in input string
    command = strtok(0, "&");
}

The advantage here is that no dynamic memory allocation takes place; you can even declare input as a local variable inside a function that would read the commands and execute them; once the function is returned the size occupied by input (in the stack) is recovered.

878: <p>I am sending a list of servo positions via the serial connection to the arduino in the following format</p>

<pre><code>1:90&amp;2:80&amp;3:180
</code></pre>

<p>Which would be parsed as:</p>

<p><code>servoId : Position &amp; servoId : Position &amp; servoId : Position</code></p>

<p>How would I split these values up, and convert them to an integer?</p>
 42035: <pre><code>char str[] = "1:90&amp;2:80&amp;3:180";     // test sample serial input from servo
int servoId;
int position;

char* p = str;
while (sscanf(p, "%d:%d", &amp;servoId, &amp;position) == 2)
{
    // process servoId, position here
    //
    while (*p &amp;&amp; *p++ != '&amp;');   // to next id/pos pair
}
</code></pre>
 43756: <p><em>jfpoilpret</em> provided great <a href="https://arduino.stackexchange.com/a/1033/43756">answer</a> for parsing serial command on Arduino. However Attiny85 doesn't have bidirectional serial - SoftwareSerial has to be used. This is how you port same code for Attiny85</p>

<pre class="lang-c prettyprint-override"><code>#include &lt;SoftwareSerial.h&gt;

// Calculate based on max input size expected for one command
#define INPUT_SIZE 30

// Initialize SoftwareSerial
SoftwareSerial mySerial(3, 4); // RX=PB3, TX=PB4

// Parameter for receiving Serial command (add 1 for final 0)
char input[INPUT_SIZE + 1];

void setup() {
  mySerial.begin(9600);
}

void loop() {
  // We need this counter to simulate Serial.readBytes which SoftwareSerial lacks
  int key = 0;

  // Start receiving command from Serial
  while (mySerial.available()) {
    delay(3);  // Delay to allow buffer to fill, code gets unstable on Attiny85 without this for some reason
    // Don't read more characters than defined
    if (key &lt; INPUT_SIZE &amp;&amp; mySerial.available()) {
      input[key] = mySerial.read();
      key += 1;
    }
  }

  if (key &gt; 0) {
    // Add the final 0 to end the C string
    input[key] = 0;

    // Read each command pair
    char* command = strtok(input, "&amp;");
    while (command != 0)
    {
      // Split the command in two values
      char* separator = strchr(command, ':');
      if (separator != 0)
      {
        // Actually split the string in 2: replace ':' with 0
        *separator = 0;
        int servoId = atoi(command);
        ++separator;
        int position = atoi(separator);
      }
      // Find the next command in input string
      command = strtok(0, "&amp;");
    }
  }
}
</code></pre>

<p>Attiny85 schematics for pin numbers
<a href="https://i.stack.imgur.com/IxwmX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IxwmX.png" alt="enter image description here"></a></p>

<p>Sketch compiles into:</p>

<pre><code>Sketch uses 2244 bytes (27%) of program storage space. Maximum is 8192 bytes.
Global variables use 161 bytes (31%) of dynamic memory, leaving 351 bytes for local variables. Maximum is 512 bytes.
</code></pre>

<p>So there is plenty of space and memory for the rest of code</p>
 7788: <pre><code>String getValue(String data, char separator, int index)
{
    int maxIndex = data.length() - 1;
    int j = 0;
    String chunkVal = "";

    for (int i = 0; i &lt;= maxIndex &amp;&amp; j &lt;= index; i++)
    {
        chunkVal.concat(data[i]);

        if (data[i] == separator)
        {
            j++;

            if (j &gt; index)
            {
                chunkVal.trim();
                return chunkVal;
            }

            chunkVal = "";
        }
        else if ((i == maxIndex) &amp;&amp; (j &lt; index)) {
            chunkVal = "";
            return chunkVal;
        }
    }   
}
</code></pre>
 7899: <p><strong>See example at:</strong>
<a href="https://github.com/BenTommyE/Arduino_getStringPartByNr" rel="nofollow noreferrer">https://github.com/BenTommyE/Arduino_getStringPartByNr</a></p>

<pre><code>// splitting a string and return the part nr index split by separator
String getStringPartByNr(String data, char separator, int index) {
    int stringData = 0;        //variable to count data part nr 
    String dataPart = "";      //variable to hole the return text

    for(int i = 0; i&lt;data.length()-1; i++) {    //Walk through the text one letter at a time
        if(data[i]==separator) {
            //Count the number of times separator character appears in the text
            stringData++;
        } else if(stringData==index) {
            //get the text when separator is the rignt one
            dataPart.concat(data[i]);
        } else if(stringData&gt;index) {
            //return text and stop if the next separator appears - to save CPU-time
            return dataPart;
            break;
        }
    }
    //return text if this is the last part
    return dataPart;
}
</code></pre>
 13432: <p>Simplest solution is to use <a href="http://www.cplusplus.com/reference/cstdio/scanf/" rel="noreferrer">sscanf()</a>.</p>

<pre><code>  int id1, id2, id3;
  int pos1, pos2, pos3;
  char* buf = "1:90&amp;2:80&amp;3:180";
  int n = sscanf(buf, "%d:%d&amp;%d:%d&amp;%d:%d", &amp;id1, &amp;pos1, &amp;id2, &amp;pos2, &amp;id3, &amp;pos3);
  Serial.print(F("n="));
  Serial.println(n);
  Serial.print(F("id1="));
  Serial.print(id1);
  Serial.print(F(", pos1="));
  Serial.println(pos1);
  Serial.print(F("id2="));
  Serial.print(id2);
  Serial.print(F(", pos2="));
  Serial.println(pos2);
  Serial.print(F("id3="));
  Serial.print(id3);
  Serial.print(F(", pos3="));
  Serial.println(pos3);
</code></pre>

<p>This give the following output:</p>

<pre><code>n=6
id1=1, pos1=90
id2=2, pos2=80
id3=3, pos3=180
</code></pre>

<p>Cheers!</p>
 27: <p>You can use <a href="http://arduino.cc/en/Reference/StreamReadStringUntil"><code>Stream.readStringUntil(terminator)</code></a> passing a different terminator for each part.</p>

<p>On each part you then call <a href="http://arduino.cc/en/Reference/StringToInt"><code>String.toInt</code></a></p>
 666: <p>You could do something like the following, but please take into account several things:</p>

<p>If you use <code>readStringUntil()</code>, it will wait until it receives the character or timeouts. Thus, with your current string, the last position will last a little longer, as it has to wait. You can add a trailing <code>&amp;</code> to avoid this timout. You can easily check this behavior in your monitor, try to send the string with and without the extra <code>&amp;</code> and you will see such timeout delay.</p>

<p>You actually do not need the servo index, you can just send your string of positions, and get the servo index by the value position in the string, something like: <code>90&amp;80&amp;180&amp;</code>. If you use the servo index, maybe you want to check it (convert to <code>int</code>, and then match the loop index i) to ensure that nothing went wrong with your message.</p>

<p>You have to check that the returning string from <code>readStringUntil</code> is not empty. If the function timeouts, you didn't receive enough data, and thus any attempt to extract your <code>int</code> values will produce strange results.</p>

<pre><code>void setup() {
    Serial.begin(9600);
}

void loop() {
    for(int i=1; i&lt;=3; i++) {
        String servo = Serial.readStringUntil(':');
        if(servo != ""){
            //here you could check the servo number
            String pos = Serial.readStringUntil('&amp;');
            int int_pos=pos.toInt();
            Serial.println("Pos");
            Serial.println(int_pos);
        }
    }
}
</code></pre>
 1115: <p>This function can be used to separate a string into pieces based on what the separating character is.  </p>

<pre><code>String xval = getValue(myString, ':', 0);
String yval = getValue(myString, ':', 1);

Serial.println("Y:" + yval);
Serial.print("X:" + xval);
</code></pre>

<p>Convert String to int</p>

<pre><code>int xvalue = xvalue.toInt(xval);
int yvalue = yvalue.toInt(yval);
</code></pre>

<p>This Chunk of code takes a string and separates it based on a given character and     returns
The item between the separating character  </p>

<pre><code>String getValue(String data, char separator, int index)
{
    int found = 0;
    int strIndex[] = { 0, -1 };
    int maxIndex = data.length() - 1;

    for (int i = 0; i &lt;= maxIndex &amp;&amp; found &lt;= index; i++) {
        if (data.charAt(i) == separator || i == maxIndex) {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i+1 : i;
        }
    }
    return found &gt; index ? data.substring(strIndex[0], strIndex[1]) : "";
}
</code></pre>
 84: <p>Contrarily to other answers, I'd rather stay away from <code>String</code> for the following reasons:</p>

<ul>
<li>dynamic memory usage (that may quickly lead to <strong>heap fragmentation</strong> and <strong>memory exhaustion</strong>)</li>
<li><strong>quite slow</strong> due to construction/destruction/assignment operators</li>
</ul>

<p>In an embedded environment like Arduino (even for a Mega that has more SRAM), I'd rather use <strong>standard C functions</strong>:</p>

<ul>
<li><a href="http://www.cplusplus.com/reference/cstring/strchr/"><code>strchr()</code></a>: search for a character in a C string (i.e. <code>char *</code>)</li>
<li><a href="http://www.cplusplus.com/reference/cstring/strtok/"><code>strtok()</code></a>: splits a C string into substrings, based on a separator character </li>
<li><a href="http://www.cplusplus.com/reference/cstdlib/atoi/"><code>atoi()</code></a>: converts a C string to an <code>int</code></li>
</ul>

<p>That would lead to the following code sample:</p>

<pre class="lang-c prettyprint-override"><code>// Calculate based on max input size expected for one command
#define INPUT_SIZE 30
...

// Get next command from Serial (add 1 for final 0)
char input[INPUT_SIZE + 1];
byte size = Serial.readBytes(input, INPUT_SIZE);
// Add the final 0 to end the C string
input[size] = 0;

// Read each command pair 
char* command = strtok(input, "&amp;");
while (command != 0)
{
    // Split the command in two values
    char* separator = strchr(command, ':');
    if (separator != 0)
    {
        // Actually split the string in 2: replace ':' with 0
        *separator = 0;
        int servoId = atoi(command);
        ++separator;
        int position = atoi(separator);

        // Do something with servoId and position
    }
    // Find the next command in input string
    command = strtok(0, "&amp;");
}
</code></pre>

<p>The advantage here is that no dynamic memory allocation takes place; you can even declare <code>input</code> as a local variable inside a function that would read the commands and execute them; once the function is returned the size occupied by <code>input</code> (in the stack) is recovered.</p>
