| View previous topic :: View next topic |
| Author |
Message |
NewzNZ Halfop

Joined: 05 Mar 2009 Posts: 60
|
Posted: Tue Mar 31, 2015 11:05 pm Post subject: splitting a $var in half |
|
|
Hi - have searched the forum, but can't quite find what I need.
Just wanting to split a $var in half and insert another character in the middle.
eg. make: $abcdef into: $abc-def
The $var is always 6 characters long, and the split I want to make is always in the middle 3 and 3.
Thanks for any help! |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue Mar 31, 2015 11:26 pm Post subject: |
|
|
Try this... | Code: | | set var "[string range $var 0 2]-[string range $var 3 5]" |
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
NewzNZ Halfop

Joined: 05 Mar 2009 Posts: 60
|
Posted: Tue Mar 31, 2015 11:31 pm Post subject: |
|
|
| That works beautifully...thanks SpiKe^^! |
|
| Back to top |
|
 |
|