Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to compare a single char in a string?

Status
Not open for further replies.

RajVerma

Programmer
Jun 11, 2003
62
DE
hi all,
is there any way to get the lrange according to the characters of the list instead of lindex. for example if I have a string "xwinnmr/tcl/acqu.txt" and I want to convert it to "xwinnmr\tcl\acqu.txt" that can be used by windows. so I want to check for every slash and copy the string in between the slashes to a buffer and then write a new string with "buff1\buff2\buff3". is this possible?
thanq.
 
Suppose "t1" is your starting string (with "/"s).
regsub -all {/} $t1 {\\} t2
Then "t2" will now have "\"s.

Bob Rashkin
rrashkin@csc.com
 
To translate a string from "xwinnmr/tcl/acqu.txt" to "xwinnmr\tcl\acqu.txt" the better (and simpler) is:
Code:
  set new_string [string map {/ \\} $old_string]
HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top