12-30-2014 03:33 PM
Is there a way to use lookbehind for a few possible letters as a whole? In the example below, I need ABC, DEF, GHI be found as a whole (ABCDE is ok), but seems like it was taken as each letter. I tried (ABC|DEF|GHI), it’s not working, one word is working. Any suggestions?
var='ABC 1.89 DEF A YELLOW LINES'; output;
var='ABC 1.89 YELLOW JKLM LINE'; output;
var='9 GHI YELLOW LINE'; output;
var='9 H BLK LINE'; output;
var='9 BC JT GREEN LINE'; output;
if _N_=1 then do;
re1 = prxparse('/(?<=[ABC|DEF|GHI] )(YELLOW|BLK|GREEN)(?=\s*LI)/');
if prxmatch(re1,var) then do;
var2 = prxposn(re1,0,var);
proc print data=b; run;
ABC 1.89 DEF A YELLOW LINES
ABC 1.89 YELLOW JKLM LINE
9 GHI YELLOW LINE
9 H BLK LINE
9 BC JT GREEN LINE
12-30-2014 04:14 PM
For example if I have “re1 = prxparse('/(?<=ABC).*(\bYELLOW|BLK|GREEN\b)(?=\s*LI)/');” in code, so ‘YELLOW’ in “ABC 1.89 DEF A YELLOW LINES” will be captured, but I need to list more possible words, like GHI, so YELLOW in “9 GHI YELLOW LINE”’ can be captured too.
Need further help from the community? Please ask a new question.