yang.zhang Posted October 27, 2014 Posted October 27, 2014 hi I have a question about the regexp re_search function i found it only could give the last match result. example: string ddd="float A1;float A2;float A3;"; int test[0]; int result=re_search(ddd,".*\bfloat \b(\w+)",test); it only return the last one "A3" , how should i do to make it return all "A1“ ”A2“ ”A3“? thanks
necris Posted October 27, 2014 Posted October 27, 2014 Hello, string ddd="float A1;float A2;float A3;"; int test[0]; int strings[0]; while(re_search(ddd,"\bfloat \b(\w+)",test)) { strings.append(test[0]); ddd = substr(ddd,strstr(ddd,test[0])); } forloop(int i = 0; strings.size()) { log.message(strings[i] + "\n"); }
Recommended Posts