lebesgue
lebesgue

Reputation: 1113

How to do string substitution in expect?

Say I have the following variable s: set s [lindex $argv 0]

How can I make sure s does not contain any "-" characters?

So, basically I want to replace all occurrences of "-" in s with "".

How can I achieve it?

Upvotes: 1

Views: 488

Answers (1)

Colin Macleod
Colin Macleod

Reputation: 4372

Use set s [string map { - {} } [lindex $argv 0]]

As pynexj says, details can be found at http://www.tcl-lang.org/man/tcl/TclCmd/string.htm#M34

Upvotes: 1

Related Questions