This should get you pretty close to what you want.
int val[10]; // variable used to store data from serial port
int ByteCount = 0;
void setup() {
Serial.begin(9600); // connect to the serial port
Serial.println("Arduio Online");
}
void loop() {
if (Serial.available() > 0) {
delay(100);
while (Serial.available() > 0) {
ByteCount ++;
val[ByteCount] = Serial.read();
}
}
if (ByteCount > 0) {
for (int i = 1; i <= ByteCount; i++) {
if (val[i] >= '0' && val[i] <= '9' ) {
val[i]= val[i] - '0';
Serial.print(val[i]);
}
}
Serial.println();
ByteCount = 0;
}
}