Performs a pattern-matching replacement.
Category: | Character String Matching |
Restriction: | Use with the PRXPARSE function. |
Interaction: | When invoked by the %SYSCALL macro statement, CALL PRXCHANGE 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 a pattern identifier that is returned from the PRXPARSE function.
is a numeric constant, variable, or expression that specifies the number of times to search for a match and replace a matching pattern.
Tip | If the value of times is -1, then all matching patterns are replaced. |
specifies the character expression on which to perform a search and replace.
Tip | All changes are made to old-string if you do not use the new-string argument. |
specifies a character variable in which to place the results of the change to old-string.
Tip | If you use the new-string argument in the call to the PRXCHANGE routine, then old-string is not modified. |
is a numeric variable with a return value that is the number of characters that are copied into the result.
Tip | Trailing blanks in the value of old-string are not copied to new-string, and are therefore not included as part of the length in result-length. |
is a numeric variable with a returned value that is either 0 or 1, depending on the result of the change operation:
0 | if the entire replacement result is not longer than the length of new-string. |
1 | if the entire replacement result is longer than the length of new-string. |
is a numeric variable with a returned value that is the total number of replacements that were made. If the result is truncated when it is placed into new-string, the value of number-of-changes is not changed.
data _null_;
/* Use a pattern to replace all occurrences of cat, */
/* rat, or bat with the value TREE. */
length text $ 46;
RegularExpressionId = prxparse('s/[crb]at/tree/');
text = 'The woods have a bat, cat, bat, and a rat!';
/* Use CALL PRXCHANGE to perform the search and replace. */
/* Because the argument times has a value of -1, the */
/* replacement is performed as many times as possible. */
call prxchange(RegularExpressionId, -1, text);
put text;
run;