23,117
社区成员
发帖
与我相关
我的任务
分享
#!/usr/bin/nawk -f
BEGIN {
FS = "|"
}
0 == 0 {
for ( count = 1; count <= NF; count++) {
if (($count == "$$$") || ($count == "^"))
break
print $count
}
}
#include <stdio.h>
#include <string.h>
#define BUFLEN 1024
static int filter(char *str);
int
main(void)
{
char buf[BUFLEN + 1];
strcpy(buf, "北京#2||erif|23|yu||||||a|^|||$$$");
printf("%s\n", buf);
filter(buf);
printf("%s\n", buf);
strcpy(buf, "黑白hg|er|nmd|2||||反对法||||||反对jdjf|$$$");
printf("%s\n", buf);
filter(buf);
printf("%s\n", buf);
return (0);
}
static int
filter(char *str)
{
char *p, *q;
p = strstr(str, "$$$");
q = strstr(str, "^");
if (p != NULL)
*p = 0;
if (q != NULL)
*q = 0;
for (p = str; *p; p++)
if (*p == '|')
*p = '\n';
return (0);
}
$ cat love.c && make love && ./love
#include <stdio.h>
#include <string.h>
#define BUFLEN 1024
static int filter(char *str);
int
main(void)
{
char buf[BUFLEN + 1];
strcpy(buf, "北京#2||erif|23|yu||||||a|^|||$$$");
printf("%s\n", buf);
filter(buf);
printf("%s\n", buf);
strcpy(buf, "黑白hg|er|nmd|2||||反对法||||||反对jdjf|$$$");
printf("%s\n", buf);
filter(buf);
printf("%s\n", buf);
return (0);
}
static int
filter(char *str)
{
char *p, *q;
p = strstr(str, "$$$");
q = strstr(str, "^");
if (p != NULL)
*p = 0;
if (q != NULL)
*p = 0;
for (p = str; *p; p++)
if (*p == '|')
*p = '\n';
return (0);
}
cc love.c -o love
北京#2||erif|23|yu||||||a|^|||$$$
北京#2
erif
23
yu
a
^
黑白hg|er|nmd|2||||反对法||||||反对jdjf|$$$
黑白hg
er
nmd
2
反对法
反对jdjf
$