Could you explain how your
regsub command "didn't work"? I see two problems with the example you posted. Assuming that the input string is stored in the variable
string, you need a "$" in front of the variable name to get its value:
[tt]regsub -all {.bri.meta}
$string {} stringout[/tt]
There is also a slight problem with your regular expression, although it should still have worked for the most part. In a regular expression "." matches any single character. To match a literal ".", you need to escape it with a "\":
[tt]regsub -all {
\.bri
\.meta} $string {} stringout[/tt]
But for simple string substitutions like this (substituting constant string values), the
string map command is more efficient and easier to use. Just make sure that you're using Tcl 8.1.1 or later, which is when the
string map command was introduced. In this case, you could simply say:
Code:
set stringout [string map {.bri.meta {}} $string]
- Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax