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 

Remove character of a list

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


Joined: 15 Mar 2015
Posts: 317

PostPosted: Tue Jun 09, 2015 12:02 am    Post subject: Remove character of a list Reply with quote

I would like the list that is stored in the cursong variable, if present the character "Ã" is removed.
But I do not want to replace the space or another character, simply remove it.
Example: if the cursong variable returns: We are the wÃorld
To return: We are the world
_________________
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks Smile
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Jun 09, 2015 12:35 am    Post subject: Reply with quote

A combination of lsearch to find it's position and lremove to remove the element in said position will do what you asked for.
Code:

set pos [lsearch $cursong "Ã"]
if {$pos != -1} {
   set cursong [lreplace $cursong $pos $pos]
}

But this will replace only the first match it will find, meaning if you got two à characters then only the first one will be replaced. To remove all the occurrences of this character you could use string map instead:
Code:

set cursong [string map [list "Ã" ""] $cursong]

_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Tue Jun 09, 2015 3:04 am    Post subject: Reply with quote

Perfect! Thanks caesar Very Happy
_________________
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks Smile
Back to top
View user's profile Send private message
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