| View previous topic :: View next topic |
| Author |
Message |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Tue Jun 13, 2006 10:57 am Post subject: Delete some characters |
|
|
Hello!
I have a script that stores some names in a textfile. Is it possible that special characters will be deleted before it is stored in the file?
For example my bot should save this name: "-{SFR}-Nick" but it should delete the "{" and "}" so that in the textfile there is only "-SFR-Nick". |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Tue Jun 13, 2006 11:48 am Post subject: |
|
|
| Code: | | set nick [string map {\{ "" \} ""} $nick] |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Thu Jun 15, 2006 10:34 am Post subject: |
|
|
| OK, thank you, it works, but there is a problem. If there are numbers in the name, my bot does not delete the "{" and the "}". For example: if the nick is "-{SFR}-Nick123", my bot should save this nick in this way: "-SFR-Nick123", but it does not delete the "{" and the "}". This problem only appears if there are numbers in the name. Can anyone help me? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Thu Jun 15, 2006 12:31 pm Post subject: |
|
|
| Quote: | Tclsh8.4:
% set foo -{SFR}-Nick123
-{SFR}-Nick123
% set foo [string map {\{ "" \} ""} $foo]
-SFR-Nick123
% |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Thu Jun 15, 2006 2:01 pm Post subject: |
|
|
| OK, I made a mistake. In the nick I used there were other escape characters like "[" and "]". I deleted them with string map, too, because otherwise the "{" and the "}" would not be deleted. |
|
| Back to top |
|
 |
|