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.

preserving text/strings which include special charactors

Old posts that have not been replied to for several years.
Locked
D
DayCuts
Voice
Posts: 37
Joined: Tue Jun 15, 2004 8:43 am

preserving text/strings which include special charactors

Post by DayCuts »

Is there a way of preserving (sorta like how [pre] tags work in php) a string in tcl?

My problem is this... my script tracks certain data in a channel. This data is kept in a tcllist. Each time the script is triggered it runs a regex check to see that the data (text/arg) is in the correct format. It then performs a regex search of the tcl list to see if a record exists already for $nick. and either updates or adds new depending on its findings.

The problem i seem to be having is with nicknames that have special charactors, such as []{}\
Because these charactors also have special meaning in regular expressions, i create a $nick2 by using a regsub and putting escapes in. Which solves the propblem for that part of the script.

However the entries in the tcl list are of similar format to "timestamp nick rest of data".

The problem i have been unsuccessful in solving is with the {}\ charactors. Both the replace/update section of that proc, and other parts of the script, manipulate or read/output data from that list.

Because of this i can not store data within the list with escape charactors as they will be processed and lost quite quickly. (in cases of their being a \ in the nickname, it simple ends up disappearing).

Apart from the fact that a nickname such as {{my}nick}} would cause problems with manipulating the tcl list entries (due to the uneven open/close braces). I am also unable to output the data correctly for the same reason (error stating list entry followed by "}" instead of space).

I have tried several methods of overcoming this, such as regsub's for those charactors. This solves most of the internal issues (even though it is undesirable for the nick in the list entries to have certain charactors replaced) but still leaves the problem of outputting data as replacing the original charactors during output causing the same issue with uneven open/close braces, or the dropping of \ charactors.

The only way i know how to preserv a string at all in tcl is by placing it inside {} braces.... however obviously this is a null feature for data that itself contains these charactors.

Sorry if this is long winded and difficult to understand, but i did not feel it wise to post the code to the public. Due to the type of data it is used to track and the potential for it to be used in the wrong way.

If anybody has any idea's on overcoming this problem please reply, it would be greatly appreciated... typical examples of a nicknames that would cause problems could be {{da}v\in\ci}} & {{da}v\inci\ (it is unusual and rare to see nicks in such a format, but it occurs non-the-less)
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

maybe show your current script maybe, can be fixed instead of making a new
XplaiN but think of me as stupid
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

small through in...
do you really need regexp? if youd use string match, you shouldnt be trouble by such things.

in case of the disapearing escape characters, you would have to track when they will proced and recreate them if necessary.
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...
D
DayCuts
Voice
Posts: 37
Joined: Tue Jun 15, 2004 8:43 am

Post by DayCuts »

Unfortunately the problem does not lie with the regular expressions. It stems from the handling of {, } and \ charactors in embedded tcl lists and the related list functions. Limitation of the language i suppose, thanks for taking the time to read.
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

Take a read of this it may or may not help you.

Click.
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
Locked