View Code
string result; string str = "uid=1000012(as) gid=1000000(domain users) groups=1000000(domain users),1000015(ABD/users),1000015(ABD/s)"; int cur_pos = 0; int left_pos = 0; int right_pos = 0; int offset = 0; while(1) { left_pos = str.find('(',cur_pos); right_pos = str.find(')',cur_pos); if(left_pos == -1 || right_pos == -1) break; cur_pos = left_pos + 1; offset = right_pos - left_pos - 1; result = str.substr(cur_pos,offset); printf("%s\n",result.c_str()); cur_pos = right_pos +1; }