This command is used to match a RegExp to a string. Substitution is made for zero or more matching substring(s) of the string, the result of this substitution being assigned to a program variable.
The synopsis of the regsub command is as follows:
regsub ?switches?
This argument is optional.
If it is included, it starts with a hyphen, or '-'.
Switches include the following: Replace all matching substrings of string.
Absent this switch, only the first (leftmost) is replaced. All letters in string will be assumed lower case
for the purpose
of matching the regular expression exp. This is the last switch if it is used.
If the exp (regexp) argument
starts with the character '-',
hen the switches argument should end in
this character to prevent misinterpretation.
?switches?
-all
-nocase
--
The second argument of the regsub command.
It is interpreted as a regular expression.
exp
This can be any string.
It either 'matches' the regular expression exp
(the second argument of regsub),
or it does not.
If it does, the (environment?) variable
whose name is given by varName
is assigned the value obtained
by replacing the first substring in this string
that matches exp with the string
used as the fourth argument, subSpec.
string
As mentioned under string,
This is the replacement string. This behavior can be modified with the use of backslashes.
It is most accepted to enclose subSpec in {curly braces}
if it contains backslashes.
subSpec
This is the name of a variable.