- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 04-07-2010 02:38 PM
(5268 views)
Hi,
I was coding a macro and I decided to cut corners and use PRX on it.
But I found one detail that I could not understand (mind that i'm a newbie when it gets to macros and macro quoting :p).
My question is this:
why is that the folowing statements don't work or give incorrect results:
%put %sysfunc(prxmatch(/\d/,123));
%put %sysfunc(prxmatch('/\d/',123));
%put %sysfunc(prxmatch(%nrbquote(/\d/),123));
%put %sysfunc(prxmatch(%nrbquote('/\d/'),123));
the only way I got it to work was:
%put %sysfunc(prxmatch(%nrbquote('\d'),123));
Can anyone explain this to me??
Thanks in advance
Pedro Glória
I was coding a macro and I decided to cut corners and use PRX on it.
But I found one detail that I could not understand (mind that i'm a newbie when it gets to macros and macro quoting :p).
My question is this:
why is that the folowing statements don't work or give incorrect results:
%put %sysfunc(prxmatch(/\d/,123));
%put %sysfunc(prxmatch('/\d/',123));
%put %sysfunc(prxmatch(%nrbquote(/\d/),123));
%put %sysfunc(prxmatch(%nrbquote('/\d/'),123));
the only way I got it to work was:
%put %sysfunc(prxmatch(%nrbquote('\d'),123));
Can anyone explain this to me??
Thanks in advance
Pedro Glória
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How about a reply to explain in non-PRX language-speak, what it is you want to accomplish? Suggest a BEFORE and AFTER data-string, if you would -- there may be other options to you, not involving PRX.
Scott Barry
SBBWorks, Inc.
Scott Barry
SBBWorks, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
These examples are just a reduction of my problem, on those examples I want each line to output 1 to the log.
I just realy want to understand the reason for me not getting to use the slash '/' on the regex when I use the PRX functions inside a %sysfunc.
On the last of my examples I got it working, so it's just to kill my curiosity.
Thanks 😉
I just realy want to understand the reason for me not getting to use the slash '/' on the regex when I use the PRX functions inside a %sysfunc.
On the last of my examples I got it working, so it's just to kill my curiosity.
Thanks 😉
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Found the problem,
The prxmatch function has 2 versions one that gets a regular-expression-id and the other a perl-regular-expression has the firt parameter.
SAS checks the first char in the string, and if it is a number or a aritmetic operator it %evals() the parameter.
So, doing:
%let regex_id=%sysfunc(prxparse(/\d/));
%put %sysfunc(prxmatch(®ex_id,123));
Works like a charm 😉
The prxmatch function has 2 versions one that gets a regular-expression-id and the other a perl-regular-expression has the firt parameter.
SAS checks the first char in the string, and if it is a number or a aritmetic operator it %evals() the parameter.
So, doing:
%let regex_id=%sysfunc(prxparse(/\d/));
%put %sysfunc(prxmatch(®ex_id,123));
Works like a charm 😉