data="John Doe^1/1/1950^123 South St^Cincinatti^Ohio^99999"
Getting the date of birth, which is in piece 2, is:
W $P(data,"^",2)
returning 1/1/1950
I'm not a c/c++ programmer, but here is the piece function for the widgets based application I am doing. The function is called with args data, delimiter, piece number:
x=piece(data,"^",3)
Code: Select all
wxString piece(wxString data, wxChar *delim, int piece)
{
wxString str="";
if (piece==1||(!piece)) {str=data.BeforeFirst(*delim);return(str);} //known quantity
int i,ndelims=0,delpos[]={};
unsigned int ii;
for (ii=0;ii<strlen(data);ii++) {if (data[ii]==*delim) {ndelims++;delpos[ndelims]=ii;}}
int pos1=delpos[piece-1],pos2=delpos[piece];
for (i=pos1+1;i<pos2;i++) {str=str+data[i];}
return(str);
}
Jimmo