zoukankan      html  css  js  c++  java
  • loadrunner通过C语言实现自定义字符出现次数截取对应字符串

    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

  • 相关阅读:
    模-数(A/D)转换器
    数-模(D/A)转换器
    VIM 常用命令
    Linux常用命令
    一个开关电源传导、辐射处理案例-----Layout环路
    解决:PADS导入.DXF结构图出现坐标超出范围问题
    Python3-threading模块-多线程
    Python3-socketserver模块-网络服务器框架
    Python3-socket模块-低级网络接口
    Python3-面向对象
  • 原文地址:https://www.cnblogs.com/qmfsun/p/4947533.html
Copyright © 2011-2022 走看看