egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

splitting a $var in half

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
NewzNZ
Halfop


Joined: 05 Mar 2009
Posts: 60

PostPosted: Tue Mar 31, 2015 11:05 pm    Post subject: splitting a $var in half Reply with quote

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
View user's profile Send private message Visit poster's website
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Tue Mar 31, 2015 11:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
NewzNZ
Halfop


Joined: 05 Mar 2009
Posts: 60

PostPosted: Tue Mar 31, 2015 11:31 pm    Post subject: Reply with quote

That works beautifully...thanks SpiKe^^!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber