|
|
楼主

楼主 |
发表于 2010-4-2 13:05:04
|
只看该作者
求助,正则表达式处理中文描述的问题
利用已给出的关键字来找出在中文描述中含有该关键字的观测.
/*生成测试数据集*/
data data_src;
length desc $300;
input desc;
cards;
程斌因癌症而到医院治疗
;
run;
data test;
set data_src;
if _N_ = 1 then do;
retain patternID1;
retain patternID2;
pattern1 = "/瘫/";
pattern2 = "/癌/";
patternID1 = prxparse(pattern1);
patternID2 = prxparse(pattern2);
if prxmatch(patternID1,desc)^=0 then do;
call prxsubstr(patternID1,desc, position, length);
if position ^= 0 then do;
match = substr(desc, position, length);
end;
end;
else if prxmatch(patternID2,desc)^=0 then do;
call prxsubstr(patternID2,desc, position, length);
if position ^= 0 then do;
match = substr(desc, position, length);
end;
end;
run;
逻辑结果 match='癌'
运行结果 match='瘫'.
初步判断 一个中文字符被拆成了两个8位的字符 '程'的第二个字符和'斌'的第一个字符 正好是'瘫'的分解.
谁能帮我纠正这个错误.very very 感谢 |
|