Performing character substitution on a string
If regexp
is a Find
function, then regsub
is equivalent to Find and Replace
. The regsub
command accepts a string and using Regular Expression pattern matching, it locates and, if desired, replaces the pattern with the desired value. The syntax of regsub
is similar to regexp
as are the switches. However, additional control over the substitution is added. The switches are as listed next:
Switch |
Description |
---|---|
|
Causes the command to perform substitution for each match found The & and \n sequences are handled for each substitution |
|
Allows use of expanded regular expression wherein whitespace and comments are ignored |
|
Enables newline-sensitive matching similar to passing the |
|
Changes the behavior of [^] bracket expressions so that they stop at newline characters |
|
Changes the behavior of ^ and $ (anchors) so that they match both the beginning and end of... |