这是C的原程序
#include <stdio.h>
#include <regex.h>
int main(int argc, char** argv)
{
regex_t reg;
regmatch_t pm[10];
char *pattern;
char buf[50];
const size_t nmatch = 10;
pattern = argv[1];
int result = regcomp(®, pattern, REG_EXTENDED);
while( fgets(buf, sizeof(buf), stdin) )
{
int e = 0;
if ( e = strlen(buf) > 0 && buf[e-1] == '\n' )
buf[e-1] = 0;
result = regexec( ®, buf, nmatch, pm, REG_NOTBOL );
if ( result == REG_NOMATCH )
continue;
int i = 0;
for ( i = 0; i < nmatch && pm[i].rm_so != -1; ++i )
{
char c[50] ;
strncpy( c, buf + pm[i].rm_so, pm[i].rm_eo - pm[i].rm_so );
c[pm[i].rm_eo - pm[i].rm_so] = 0;
printf("%d,%d:%s\n", pm[i].rm_so, pm[i].rm_eo,c);
}
}
}
这是测试文件内容:
的rqyy rqyy
一ggll ggll
不gii gii
是jghu jghu
了bnh bnh是jghu jghu
我trnt trnt
他wbn wbn是jghu jghu
人wwww wwww
低点wqhk
低龄wqhw是jghu jghu
俄狄浦斯wqia
斧削wqie
低潮wqif是jghu jghu
低洼wqif
低温wqij
低沉wqip
低劣wqit
仰泳wqiy
你是wqjg
像是wqjg
含金量wqjg
编译后执行
bash-4.0$ ./reg "[a-y]*$" <aaa 没有输出数据
13,13:
13,13:
11,11:
13,13:
23,23:
13,13:
23,23:
13,13:
11,11:
23,23:
17,17:
11,11:
23,23:
11,11:
11,11:
11,11:
11,11:
11,11:
11,11:
11,11:
14,14:
bash-4.0$ ./reg "[a-y]*" <aaa
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
0,0:
bash-4.0$ ./reg "[a-y]" <aaa //匹配到了一个字母
3,4:r
3,4:g
3,4:g
3,4:j
3,4:b
3,4:t
3,4:w
3,4:w
6,7:w
6,7:w
12,13:w
6,7:w
6,7:w
6,7:w
6,7:w
6,7:w
6,7:w
6,7:w
6,7:w
6,7:w
9,10:w
bash-4.0$ ./reg "[a-y]{1,}" <aaa //匹配到了结尾四个字母
3,7:rqyy
3,7:ggll
3,6:gii
3,7:jghu
3,6:bnh
3,7:trnt
3,6:wbn
3,7:wwww
6,10:wqhk
6,10:wqhw
12,16:wqia
6,10:wqie
6,10:wqif
6,10:wqif
6,10:wqij
6,10:wq
(1)简述:在编译好了的ANDROID根文件系统的system/etc/pointercal这个文件内,存放着7个数,这7个数就是《linux的触摸屏之一》所讲的a,b,c,d,e,f,s。比如我在自己的MID上查看的数值为:4933 -5 -15710176 -95 -4961 56071328 65536。
(2)处理说明:“system/etc/pointercal”这个文件是被java程序读取使用的 ......