Another way
void setup() {
Serial.begin(9600);
}
void loop() {
String data="$GPGGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh";
int maxIndex = data.length() - 1;
int index=0;
int next_index;
String data_word;
do{
next_index=data.indexOf(',',index);
data_word=data.substring(index, next_index);
Serial.print("Output line: ");
Serial.println(data_word);
index=next_index+1;
}while((next_index!=-1)&&(next_index<maxIndex));
}
Outputs:
Output line: $GPGGA
Output line: hhmmss.ss
Output line: llll.ll
Output line: a
Output line: yyyyy.yy
Output line: a
Output line: x
Output line: xx
Output line: x.x
Output line: x.x
Output line: M
Output line: x.x
Output line: M
Output line: x.x
Output line: xxxx*hh