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.

lreplace question

Old posts that have not been replied to for several years.
Locked
J
Jag
Halfop
Posts: 90
Joined: Fri Sep 19, 2003 10:06 am

lreplace question

Post by Jag »

I have the line:
1.2.3.4
How can i replace these lines to be:
1*2*3*3
With the [lreplace] command?

I have read the manual of this command, but i didn't understand.
Hope that you'll help me, thanks :)
User avatar
Rusher2K
Halfop
Posts: 88
Joined: Fri Apr 18, 2003 10:45 am
Location: Germany
Contact:

Post by Rusher2K »

You can use that :

Code: Select all

set code "1.2.3.4"

set code [string map {. *} 1.2.3.4.5] ; return $code

that returns : 2 - result: 1*2*3*4*5 - clicks: 109
Or that :

Code: Select all

set code "1.2.3.4"

regsub -all -- {\.} $code * code ; return $code

that returns : 2 - result: 1*2*3*4*5 - clicks: 416
J
Jag
Halfop
Posts: 90
Joined: Fri Sep 19, 2003 10:06 am

Post by Jag »

Thanks, it works! :)

last question, how can i regsub all the colors/bolds/italics (\003,\002\037) from line?

Thanks again :P
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Code: Select all

proc stripcolors { text } {
regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026} $text {} text
return $text
}
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

or another version:

Code: Select all

set code "1.2.3.4"
set code [join [split $code .] *]
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
J
Jag
Halfop
Posts: 90
Joined: Fri Sep 19, 2003 10:06 am

Post by Jag »

Thank you all :)
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

I've said this before...

Post by user »

GodOfSuicide wrote:

Code: Select all

regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026} $text {} text
That's not the right way to match colors. It would match things like "\003," "\003,99" "\00366," where "," and "99" are not part of the color "tag". Try this instead:

Code: Select all

regsub -all {\002|\003([0-9]{1,2}(,[0-9]{1,2})?)?|\017|\026|\037} $text {} text
Have you ever read "The Manual"?
Locked