Returns the start position and length for a capture buffer.
| Category: | Character String Matching |
| Restriction: | Use with the PRXPARSE function. |
specifies a numeric variable with a value that is a pattern identifier that is returned by the PRXPARSE function.
is a numeric constant, variable, or expression with a value that identifies the capture buffer from which to retrieve the start position and length:
is a numeric variable with a returned value that is the position at which the capture buffer is found:
data _null_;
patternID = prxparse('/(\d\d):(\d\d)(am|pm)/');
text = 'The time is 09:56am.';
if prxmatch(patternID, text) then do;
call prxposn(patternID, 1, position, length);
hour = substr(text, position, length);
call prxposn(patternID, 2, position, length);
minute = substr(text, position, length);
call prxposn(patternID, 3, position, length);
ampm = substr(text, position, length);
put hour= minute= ampm=;
put text=;
end;
run;data _null_;
if _N_ = 1 then
do;
retain patternID;
pattern = "/(\d+):(\d\d)(?:\.(\d+))?/";
patternID = prxparse(pattern);
end;
array match[3] $ 8;
input minsec $80.;
position = prxmatch(patternID, minsec);
if position ^= 0 then
do;
do i = 1 to prxparen(patternID);
call prxposn(patternID, 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
;