CALL PRXNEXT Routine
Returns the position and length of a substring that matches a pattern, and iterates over multiple matches within one string.
| Category: | Character String Matching |
| Restrictions: | Use with the PRXPARSE function. |
| This function is not valid on the CAS server. | |
| Do not use this function to process DBCS and MBCS data, because this CALL routine requires the PRXPARSE function, which is not DBCS compatible. | |
| 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. |
| Notes: | Argument types for arguments that are updated must match in CALL routines. All argument types must be CHAR, VARCHAR, or NUMERIC. If the argument types do not match, a warning is issued to the log. |
| SAS has adopted the International Components for Unicode (ICU). ICU enables SAS to apply regular expression matching to Unicode string data. For more information, see Regular Expressions. |
Syntax
Required Arguments
regular-expression-id
specifies a numeric variable with a value that is the identification number that is returned by the PRXPARSE function.
start
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.
stop
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.
source
specifies a character constant, variable, or expression that you want to search.
position
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.
length
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.
Details
Comparisons
Example
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;found=bat position=18 length=3 found=cat position=23 length=3 found=rat position=34 length=3