这个问题用常规的字符函数可能要多行才能解决,用正则表达式就相对简单了,程序如下:
data demo;
STRING='%test(var1=123, var2=abc, var3=abc123);';
REX...[,\)])/');
START=1;
STOP=length(STRING);
call prxnext(REX, START, STOP, STRING, POSITION,...PARAM)+2);
VALUE=prxchange('s/[\),]$//', -1, cats(VALUE));
output;
call prxnext(REX...=[^\(]*\)[,\)])/~/', -1, STRING);
REX=prxparse('/(\w+=.+?...[,\)]+)/');
START=1;
STOP=length(STRING);
call prxnext(REX, START, STOP, STRING, POSITION