SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
Finds the position, length, and score of a substring that matches a pattern
Category: Character String Matching
Restriction: Use with the RXPARSE function
Syntax
CALL RXSUBSTR ( rx, string, position );
CALL RXSUBSTR ( rx, string, position, length );
CALL RXSUBSTR ( rx, string, position, length, score );
Arguments
rx
-
specifies a numeric value that is returned from the RXPARSE function.
string
-
specifies the character expression to be searched.
position
-
specifies a numeric position in a string where the substring that is matched by the pattern begins. If there is no match, the result is zero.
length
-
specifies a numeric value that is the length of the substring that is matched by the pattern.
score
-
specifies an integer value based on the number of matches for a particular pattern in a substring.
Details
CALL RXSUBSTR searches the variable string for the pattern from RXPARSE, returns the position of the start of the string, indicates the length of the matched string, and returns a score value. By default, when a pattern matches more than one substring beginning at a specific position, the longest substring is selected.
Comparisons
CALL RXSUBSTR performs the same matching as RXMATCH, but CALL RXSUBSTR additionally allows you to use the length and score arguments to receive more information about the match.
The regular expression (RX) functions and CALL routines work together to manipulate strings that match patterns. Use the RXPARSE function to parse a pattern you specify. Use the RXMATCH function and the CALL RXCHANGE and CALL RXSUBSTR routines to match or modify your data. Use the CALL RXFREE routine to free allocated space.
Example
See the RXPARSE function 'Examples' on page 811.
See Also
Functions and CALL routines:
-
'CALL RXCHANGE Routine' on page 385
-
'CALL RXFREE Routine' on page 387
-
'RXMATCH Function' on page 799
-
'RXPARSE Function' on page 800