Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace particular character in string with tcl script?

set some_string "Name/is/ComplexSTRUCTUre" 

convert this string to,

some_string = "Name/is/ComplexSTR.CTUre" 

i.e replacing first "U" to "."

like image 335
Harshad_Dinfi Avatar asked May 02 '16 13:05

Harshad_Dinfi


1 Answers

Try This,

set replaced_string [regsub "U" $some_string "."]
puts $replaced_string

Another Option,

set pos [string first "U" $some_string]
set replaced_string [string replace $some_string $pos $pos "."]
puts $replaced_string

Here your "Name/is" portion should not contain any "U"

More information can be found here tcl string replacement

like image 195
mf_starboi_8041 Avatar answered Sep 28 '22 04:09

mf_starboi_8041