prxmatch issue?

Reply
Super Contributor
Posts: 319

prxmatch issue?

[ Edited ]

Hello:

 

I have the following prxmatch codes. 

 

else if prxmatch("m/(?=.*?if_audiol)/i", &var) > 0 then found=18;

else if prxmatch("m/(?=.*?if_audiol_dt)/i", &var) > 0 then found=19;

else if prxmatch("m/(?=.*?if_audiol_res)/i", &var) > 0 then found=20;

else if prxmatch("m/(?=.*?if_audiol_res_sp)/i", &var) > 0 then found=21;

else if prxmatch("m/(?=.*?mhh_exp_ustrv)/i", &var) > 0 then found=223;

else if prxmatch("m/(?=.*?mhh_exp_ustrv_en)/i", &var) > 0 then found=224;

else if prxmatch("m/(?=.*?mhh_exp_ustrv_here)(?=.*?yes)/i", &var) > 0 then found=225;

else found=0;

run;

 

 

I found out all of the follow rows have been assigned to 18 and 223, how to differentiate the following conditions with the correct numbers:

 

if_audiol_1                         18

if_audiol_2                         18

if_audiol_dt_1                      19

if_audiol_dt_2                      19

if_audiol_dt_3                      19

if_audiol_res_1                     20

if_audiol_res_2                     20

if_audiol_res_3                     20

if_audiol_res_4                     20

if_audiol_res_sp_1                  21

if_audiol_res_sp_2                  21

mhh_exp_ustrv                       223

mhh_exp_ustrv_en1                   224

mhh_exp_ustrv_here1_yes             225

 

 

 

 

 

Super User
Posts: 19,787

Re: prxmatch issue?

Change the order of your IF/ELSE IF to have the most detailed first down to the most generic. Your current system has it backwards.

Respected Advisor
Posts: 4,173

Re: prxmatch issue?

[ Edited ]

@ybz12003

Should your strings like if_audiol be "words" and not just sub-strings then you could also use the \b syntax to avoid matches with sub-strings and not whole words. ->  \bif_audiol\b

PROC Star
Posts: 1,759

Re: prxmatch issue?

I still think you do not need to read ahead. Your RegEx seems to be needlessly complex.

Ask a Question
Discussion stats
  • 3 replies
  • 120 views
  • 1 like
  • 4 in conversation