This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Replace $string1 with $string2

Help for those learning Tcl or writing their own scripts.
Post Reply
s
soulfly
Voice
Posts: 2
Joined: Tue Apr 25, 2006 11:53 pm

Replace $string1 with $string2

Post by soulfly »

Hey guy's. I was searching here for the replacement function.
But I found nothing, or I was too stupid to mange the Search :X

My problem is very simple, I think.
I want to replace * with % in $value
I tried regsub -all but it didn't worked.

Thanky you for any help.

greetz soulfly
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

Code: Select all

regsub -all {\*} $value {%} value
s
soulfly
Voice
Posts: 2
Joined: Tue Apr 25, 2006 11:53 pm

Post by soulfly »

Oh thx, I already solved by problem.
I used string map
But can u tell me wich is faster?

I have several options.
Once it should replace * and ' ' (space) by a % (for the sql query)

And other time it sould
searchfor '(', ')', '-', '.', '_'
replacew '', '', ' ', ' ', ' '

They are sorted as above + below.
Thx in future for any help
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

depends on length of string and cacheablitlity of the whole script. I'd say string map is about twice as fast. As longer the string and as more seldom it gets called cached (precompiled) as bigger will be the difference.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Post Reply