自从我用 C 语言编写程序以来已经很久了,我有一个如下所示的字符串
"VRUWFB02=I.V.R, W.F.B, plan 2, VRUWFB01=I.V.R, W.F.B, plan 1, assa=784617896.9649164, plan24, massmedua=plan12, masspedia=IVR, masojh, jhsfdkl, oijhojomn, oiafofvj, plan"
我需要得到“=”之前的那些,即VRUWFB02,VRUWFB01,assa,massmedua,masspedia。
我能够断开字符串,但无法提取那些特定的单词。
谁能帮我这个
char st[] = "VRUWFB02=I.V.R, W.F.B, plan 2, VRUWFB01=I.V.R, W.F.B, plan 1,assa=784617896.9649164, plan24, massmedua=plan12, masspedia=IVR, masojh, jhsfdkl, oijhojomn, oiafofvj, plan";
char *ch;
regex_t compiled;
char pattern[80] = " ";
printf("Split \"%s\"\n", st);
ch = strtok(st, " ");
while (ch != NULL) {
if(regcomp(&compiled, pattern, REG_NOSUB) == 0) {
printf("%s\n", ch);
}
ch = strtok(NULL, " ,");
}
return 0;