void lr_custom_string_delim_save(char inputStr[500], char* outputStr, char *delim, int occrNo, int stringSide) { char *temp, *temp2; char temp3[500] = {0}; int i = 0; int i2; int iOccrNo = 1; temp = ""; while (temp!=NULL) { if(i==0) { temp2 = temp; temp = (char *)strtok(inputStr,delim); i++; } if(i>0) { temp2 = temp; temp = (char *)strtok(NULL,delim); if (stringSide==0) { if (iOccrNo > occrNo) { strcat(temp3, temp2); if (temp!=NULL) { strcat(temp3, delim); } } } if (stringSide==1) { if (iOccrNo <= occrNo) { strcat(temp3, temp2); strcat(temp3, delim); } } iOccrNo++; } } if (stringSide==1) { for( i2 = strlen (temp3) - 1; i2 >= 0 && strchr ( delim, temp3[i2] ) != NULL; i2-- ) temp3[i2] = ' '; } lr_save_string(temp3,outputStr); } Action() { lr_save_string("chait@Agoly@H789an@ya m bhatt", "InputName"); lr_output_message("替换前的字符串=%s",lr_eval_string("{InputName}")); lr_custom_string_delim_save(lr_eval_string("{InputName}"),"test","@",3,1); lr_output_message("替换后的字符串=%s",lr_eval_string("{test}")); return 0; }
深圳湖北籍软件测试群 275212937