Reg Sub

regsum command in Tcl

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?

exp

string

subSpec varName

?switches?

This argument is optional. If it is included, it starts with a hyphen, or '-'. Switches include the following:

-all

Replace all matching substrings of string. Absent this switch, only the first (leftmost) is replaced.

-nocase

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.

exp

The second argument of the regsub command. It is interpreted as a regular expression.

string

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.

subSpec

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.

varName

This is the name of a variable.

Hosted by www.Geocities.ws

1