Searches for a pattern match and returns the position at which the pattern is found.
Category: | Character String Matching |
specifies a numeric variable with a value that is a pattern identifier that is returned from the PRXPARSE function.
Restriction | If you use this argument, you must also use the PRXPARSE function. |
specifies a character constant, variable, or expression with a value that is a Perl regular expression.
specifies a character constant, variable, or expression that you want to search.
/* For 9.0: the following example makes a call to PRXPARSE. */ /* For 9.1, no call is required. */
data _null_; if _N_ = 1 then do; retain PerlExpression; pattern = "/(\d+):(\d\d)(?:\.(\d+))?/"; PerlExpression = prxparse(pattern); end; array match[3] $ 8; input minsec $80.; position = prxmatch(PerlExpression, minsec); if position ^= 0 then do; do i = 1 to prxparen(PerlExpression); call prxposn(PerlExpression, i, start, length); if start ^= 0 then match[i] = substr(minsec, start, length); end; put match[1] "minutes, " match[2] "seconds" @; if ^missing(match[3]) then put ", " match[3] "milliseconds"; end; datalines; 14:56.456 45:32 ; run;