Here's the docs for regsub (
Click here)
regsub ?switches? exp string subSpec ?varName?
This command matches the regular expression exp against string, and either copies string to the variable whose name is given by varName or returns string if varName is not present. (Regular expression matching is described in the re_syntax reference page.) If there is a match, then while copying string to varName (or to the result of this command if varName is not present) the portion of string that matched exp is replaced with subSpec. If subSpec contains a ``&'' or ``\0'', then it is replaced in the substitution with the portion of string that matched exp. If subSpec contains a ``\n'', where n is a digit between 1 and 9, then it is replaced in the substitution with the portion of string that matched the n-th parenthesized subexpression of exp. Additional backslashes may be used in subSpec to prevent special interpretation of ``&'' or ``\0'' or ``\n'' or backslash. The use of backslashes in subSpec tends to interact badly with the Tcl parser's use of backslashes, so it's generally safest to enclose subSpec in braces if it includes backslashes.
So, this usage does the following:
regsub {.*\.telept\.com} $location $orig_host location
expression = ".*\.telept\.com"
string = $location
subSpec = $orig_host
varName = location
The regular expression is dissected like this
. = any character
* = the next 1-n matches of the previous pattern (any character)
\. = the literal "dot" character
telept = the string telept
\. = the literal "dot character
com = the string com
So this regular expression will search for 1-n characters followed by a dot followed by "telept" followed by a dot followed by "com"
So it will match the beginning of the string up and including ".telept.com"
ie. ??????.telept.com
It will then replace the first occurrance of that with $orig_host and place it in the location variable.
You said that the redirect isn't working. Can you be a bit more specific. Adding some logging with the log command could help you diagnose if the regexp is really the problem.
-Joe