Hi,
I want to use string map to eliminate a set of characters from a string. The thing is that the set of characters are saved into a variable and I haven't come up with a solution to remove these from the string.
Some code that explains the problem:
I would like the result to be
--->name
--->date
--->id
It works fine to remove the "_" character, but I need to remove the "foo" as well. It seems that the string map tries to remove a set of characters that is "$data" from the string and not the value of data.
Does anybody have a tip or solution?
I want to use string map to eliminate a set of characters from a string. The thing is that the set of characters are saved into a variable and I haven't come up with a solution to remove these from the string.
Some code that explains the problem:
Code:
set data "foo"
set form_tag(foo_name)
set form_tag(foo_date)
set form_tag(foo_id)
foreach form_variable [array names form_tag] {
set result [string map {$data "" _ ""} form_variable]
#Do some stuff using $result
#...
}
I would like the result to be
--->name
--->date
--->id
It works fine to remove the "_" character, but I need to remove the "foo" as well. It seems that the string map tries to remove a set of characters that is "$data" from the string and not the value of data.
Does anybody have a tip or solution?