INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Identifying an open unbalanced brace in a string

Identifying an open unbalanced brace in a string

Identifying an open unbalanced brace in a string

(OP)
Hi,

I need to execute a script which parses through the data line, by line. While going through the data, I come across lines which contain unbalanced braces within the data.

I was able to assign it to a list, however, while performing something like

set x [lindex $line 0]

,an error is reported mentioning there's an unbalanced brace. Now, I tried using the split function but it leads to unnecessary empty elements if there's whitespace anywhere in the line, which sounds inefficient and also doesn't help my cause(coz now my problem is deleting the extra elements, and I would need lindex 1,2... I guess u get the point...)

Also, quite obviously, I can't go ahead and manipulate the data and fetch any random [lindex $temp_line 0]

% gets $file_handler line

# Let line value be
#
# assign some_thing = {some_thing1, some_thing2,

% set temp_line $line
% set x [lindex $line 0]
>> ERROR!!

Please help me out !! (I've been cracking my head over this for some time now!! I've tried using regexp, regsub too!!)

RE: Identifying an open unbalanced brace in a string

CODE

% set s "assign some_thing = "
assign some_thing =
% append s \x7b
assign some_thing = {
% append s "some_thing1, some_thing2,"
assign some_thing = {some_thing1, some_thing2,
% regsub \{ $s \| s
1
% set s
assign some_thing = |some_thing1, some_thing2,
%

_________________
Bob Rashkin

RE: Identifying an open unbalanced brace in a string

(OP)
Thanks Bob,

That did help a lot...

RE: Identifying an open unbalanced brace in a string

Hi

Quote (eugene42):

I need to execute a script which parses through the data line, by line.
So your goal is to process Tcl code in a variable and you have problem when the code is not complete yet ? Then see info complete.
 

Feherke.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close