Posted by: Sourav | November 20, 2014

replacing a character in a string in TCL


set line “Hello how ? are you? Is your ? name Sourav ?”
set replace ” $ “
while {[string first “?” $line] != -1} {
#puts “There it is”
set start [string first “?” $line]

set end [expr {$start+1}]
incr start -1
set line [string replace $line $start $end $replace]

}

puts $line

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: