char *replace_str(char *str, char *orig, char *rep) {
static char buffer[9096];
char *p;
if(!(p = (char *)strstr(str, orig))) // Is 'orig' even in 'str'?
return str;
strncpy(buffer, str, p-str); // Copy characters from 'str' start to 'orig' st$
buffer[p-str] = '\0';
sprintf(buffer+(p-str), "%s%s", rep, p+strlen(orig));
return buffer;
}
Action()
{
lr_save_string("&ctl00%ContentPage%24cgv%24test旺仔%24testDBCommissionPaid%24ctl03", "rqParam");
lr_output_message("原始的字符串: %s", lr_eval_string("{rqParam}"));
lr_output_message("替换后字符串: %s", replace_str(lr_eval_string("{rqParam}"), "旺仔", "Agoly"));
return 0;
}
深圳湖北籍软件测试群 275212937