Hi guys, could you help to modify code since I'm not familar with PRX.
I want to extract the words including lower case letters, upper case letters and digits,(a-z,A-Z,0-9), and the length word is 8.
\w
data a;
length string $200;
string='Befor??e Bexfore1 Beforexx xxxxxxxx nightmare or On the End,..ed 1234(678 of abc abc12345 1234567_ 1 high';
run;
data a1;
length s1 $8 ;
set a;
do i=1 to countw(string,' ');
temp=scan(string,i,' ');
if prxmatch("/\w{8}?/",temp) and not index(temp,"_") then do;
s1=temp;
output;
end;
end;
run;how to modify the PRX to delete the word "nightmare" whose length is over 8? offer more than one method of PRX?
prxNext routine allows you to scan a string efficiently. Instead of using \w to mean a word character (including an underscore) and then testing for the presence of an underscore, be explicit and specify [a-zA-Z0-9]
data a1;
prxId = prxparse("/\b[a-zA-Z0-9]{8}\b/o");
set a;
start = 1; stop = -1;
call prxnext(prxID, start, stop, string, position, length);
do while (position > 0);
found = substr(string, position, length);
output;
call prxnext(prxID, start, stop, string, position, length);
end;
keep string found;
run;
prxNext routine allows you to scan a string efficiently. Instead of using \w to mean a word character (including an underscore) and then testing for the presence of an underscore, be explicit and specify [a-zA-Z0-9]
data a1;
prxId = prxparse("/\b[a-zA-Z0-9]{8}\b/o");
set a;
start = 1; stop = -1;
call prxnext(prxID, start, stop, string, position, length);
do while (position > 0);
found = substr(string, position, length);
output;
call prxnext(prxID, start, stop, string, position, length);
end;
keep string found;
run;
hi PG, thank you very much, \b match word boundary
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.