Returns the position and length of a substring that matches a pattern, and iterates over multiple matches within one string.
| Category: | Character String Matching |
| Restriction: | Use with the PRXPARSE function. |
| Interaction: | When invoked by the %SYSCALL macro statement, CALL PRXNEXT removes the quotation marks from arguments. For more information, see Using CALL Routines and the %SYSCALL Macro Statement. |
specifies a numeric variable with a value that is the identification number that is returned by the PRXPARSE function.
is a numeric variable that specifies the position at which to start the pattern matching in source. If the match is successful, CALL PRXNEXT returns a value of position + MAX(1, length). If the match is not successful, the value of start is not changed.
is a numeric constant, variable, or expression that specifies the last character to use in source. If stop is -1, then the last character is the last non-blank character in source.
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 at which the pattern begins. If no match is found, CALL PRXNEXT returns zero.
is a numeric variable with a returned value that is the length of the string that is matched by the pattern. If no match is found, CALL PRXNEXT returns zero.
data _null_;
ExpressionID = prxparse('/[crb]at/');
text = 'The woods have a bat, cat, and a rat!';
start = 1;
stop = length(text);
/* Use PRXNEXT to find the first instance of the pattern, */
/* then use DO WHILE to find all further instances. */
/* PRXNEXT changes the start parameter so that searching */
/* begins again after the last match. */
call prxnext(ExpressionID, start, stop, text, position, length);
do while (position > 0);
found = substr(text, position, length);
put found= position= length=;
call prxnext(ExpressionID, start, stop, text, position, length);
end;
run;