參看下面的代碼,想問一下Carol Echols中的Echols為什么匹配對應(yīng)的last變量?([^\s]+\s+)這個匹配到底表示的是啥意思……求高人解答,謝謝!
data old;
input name $60.;
datalines;
Judith S Reaveley
Ralph F. Morgan
Jess Ennis
Carol Echols
Kelly Hansen Huff
Judith
Nick
Jones
;
data new;
length first middle last $ 40;
re1 = prxparse('/(\S+)\s+([^\s]+\s+)?(\S+)/o');
re2 = prxparse('/(\S+)(\s+)([^\s]+\s+)(?)(\S+)/o');
set old;
id1=prxmatch(re1, name);
id2=prxmatch(re2, name);
if id1 then
do;
first = prxposn(re1, 1, name);
middle = prxposn(re1, 2, name);
last = prxposn(re1, 3, name);
end;
if id2 then test=prxposn(re1, 4, name);
put test=;
run;