Hi
I need some help to understand why this regexpression does not work and the otherone does?
Works:
prxparse('/\w[-.\w]*\@[-\w]+(\.[-\w]+)*\.(no|com|edu|gov|int|mil|net|org|biz|info|name|museum|coop|aero|[a-z][a-z])/i')
Does not work:
prxparse('/^[a-zA-Z0-9.!#$%&*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/')
I try to validate emails using this code replacing the prxparse expression that does not work.
%LET Myvariable = TheVariable;
data WORK.OUT;
re =
prxparse('/\w[-.\w]*\@[-\w]+(\.[-\w]+)*\.(no|com|edu|gov|int|mil|net|org|biz|info|name|museum|coop|aero|[a-z][a-z])/i');
do until(eof);
set _infile_ end=eof;
if ^prxmatch(re,&MyVariable) then do;
/* appropriate lines of code */
keep &Myvariable;
output;
end;
end;
run;
LOG:
SYMBOLGEN: Macro variable MYREGEXPRESION resolves to
'/^[a-zA-Z0-9.!#$%&*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a
-zA-Z0-9])?)*$/'
36 /*prxparse('/\w[-.\w]*\@[-\w]+(\.[-\w]+)*\.(no|com|edu|gov|int|mil|net|org|biz|info|name|museum|coop|aero|[a-z][a-z])/i
36 ! ');*/
37
38 do until(eof);
__
79
ERROR 79-322: Expecting a ;.
Your help is much obliged
First, the log you posted has an irrelevant syntax error...
More importantly, I feel that this is a small bug in the PRX parser where the literal '$' is being confused for a Perl variable reference. It is, thankfully, also very easy to work-around.
The below, I believe, is what you wanted, except fixed to properly comply with the RFC 2822 simplified specification (you had removed the single quotes) and the the '$' characters escaped to avoid the prx parsing error.
prxparse('/[a-z0-9!#\$%&''*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#\$%&''*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i');
data foo;
if _n_=1 then do;
retain prxid;
call prxdebug(1);
prxid=prxparse('/[a-z0-9!#\$%&''*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#\$%&''*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i');
call prxdebug(0);
end;
input email : & $400. ;
x=prxmatch(prxid,email);
cards;
president@whitehouse.gov
ip@1.2.3.123
pharaoh@egyptian.museum
john.doe+regexbuddy@gmail.com
Mike.O'Dell@ireland.com
"Mike\ O'Dell"@ireland.com
IPguy@[1.2.3.4]
===
1024x768@60Hz
not.a.valid.email
not@valid.email
john@aol...com
Mike\ O'Dell@ireland.com
;
run;
First, the log you posted has an irrelevant syntax error...
More importantly, I feel that this is a small bug in the PRX parser where the literal '$' is being confused for a Perl variable reference. It is, thankfully, also very easy to work-around.
The below, I believe, is what you wanted, except fixed to properly comply with the RFC 2822 simplified specification (you had removed the single quotes) and the the '$' characters escaped to avoid the prx parsing error.
prxparse('/[a-z0-9!#\$%&''*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#\$%&''*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i');
data foo;
if _n_=1 then do;
retain prxid;
call prxdebug(1);
prxid=prxparse('/[a-z0-9!#\$%&''*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#\$%&''*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i');
call prxdebug(0);
end;
input email : & $400. ;
x=prxmatch(prxid,email);
cards;
president@whitehouse.gov
ip@1.2.3.123
pharaoh@egyptian.museum
john.doe+regexbuddy@gmail.com
Mike.O'Dell@ireland.com
"Mike\ O'Dell"@ireland.com
IPguy@[1.2.3.4]
===
1024x768@60Hz
not.a.valid.email
not@valid.email
john@aol...com
Mike\ O'Dell@ireland.com
;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: