Returns the position and length of a substring that matches a pattern.
| Category: | Character String Matching |
| Restriction: | Use with the PRXPARSE function. |
| Interaction: | When invoked by the %SYSCALL macro statement, CALL PRXSUBSTR removes the quotation marks from its arguments. For more information, see Using CALL Routines and the %SYSCALL Macro Statement. |
specifies a numeric variable with a value that is an identification number that is returned by the PRXPARSE function.
specifies a character constant, variable, or expression that you want to search.
is a numeric variable with a returned value that is the position in source where the pattern begins. If no match is found, CALL PRXSUBSTR returns zero.
data _null_;
if _N_ = 1 then
do;
retain ExpressionID;
/* The i option specifies a case insensitive search. */
pattern = "/ave|avenue|dr|drive|rd|road/i";
ExpressionID = prxparse(pattern);
end;
input street $80.;
call prxsubstr(ExpressionID, street, position, length);
if position ^= 0 then
do;
match = substr(street, position, length);
put match:$QUOTE. "found in " street:$QUOTE.;
end;
datalines;
153 First Street
6789 64th Ave
4 Moritz Road
7493 Wilkes Place
;
run;