title: Parse digits only from mixed character string on arduino
body: <p>I am using Arduino Uno with Sim900 GSM board. In my code I use the command AT+CGSN to retrieve the IMEI from the chip. This is (in my case) a 15 digit number sequence returned as: 
  AT+CGSN</p>
  
  <p>013949150670600</p>
  
  <p>OK</p>
  
  <p>This is received by:</p>
  
  <pre><code>void GetID(){
   GPRS.print("");   
    GPRS.println("AT+CGSN");    
    delay(200);    
   {    
    while(!GPRS.available());    
    if(GPRS.available()){    
      while(GPRS.available()){    
        imei_character = GPRS.read();    
        imei_content.concat(imei_character);    
  //      delay(20);    
  //      imei_content.trim();    
  //      delay(20);      
      }
    }
    delay(1500);
  
  } 
  
  }
  </code></pre>
  
  <p>I have used .length() to determine that there are at least 10 whitespaces within the response, which puts the first digit at position 11. I know that to just parse the numbers I can use: </p>
  
  <pre><code> String getGSMid(){  
  return imei_content.substring(11, 25);
  }
  </code></pre>
  
  <p>or alternatively I can turn off command echo to remove the "AT+CSGN" then use "imei_content.trim();" to remove the leading whitespace and from there use
   return imei_content.substring(0, 15); instead.</p>
  
  <p>What I would prefer through is to look at the response regardless of what it is and find the sequence of digits and extract it based on the fact that it is a digit, to the effect of:</p>
  
  <pre><code>    String getGSMid(){         
    return imei_content.substring(imei_content.indexOf('0&gt;='),         imei_content.lastIndexOf('0&gt;='));        
  }
  </code></pre>
  
  <p>I am a novice coder, so although I have seen the likes of isdigit(), Regex, Sscanf, I am not sure if any are appropriate for my application. Ideally I would like to avoid adding a library and to keep the code as simple as possible. If I can adapt what I have to make a robust piece of code that will reliably parse the 15 digit id regardless of the return format (I realise that if there are any stray digits returned, which are not part of the ID this may throw things out, this is acceptable). It may be that disabling echo and trimming is the easiest way forward and "reliable enough" - hopefully someone can lead me in the right direction. Thank you.</p>