C语言中,截取函数整理

来源:互联网 发布:接新娘唱什么歌 知乎 编辑:程序博客网 时间:2024/06/14 05:14

在进行 写LR 脚本的时候,肯定是要熟悉C语言的一些特性的,以下把一些平时练习中的C语言的截取函数给整理出


char *string_cut(char *src, char *left, char *right)
{
    char path[1024] = "";
char *res = (char *)strstr(src,left);
res = res + strlen(left);
if(strcmp(right, "/0") == 0)
{
return res;
}


strcpy(path, res);


res = (char *)strtok(path, right); 


return res;


}


Action()
{
char *testR = "30&test111=2&最后回复时间>11-18 22:19</a></span><span>回复<em>1";
char *testR2;


testR2 = (char *)string_cut(testR, "test111=", "&");
lr_output_message("--------------------截取回复数为:%s",testR2);


return 0;
}

原创粉丝点击