Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Basic tcl question - Regarding regular expression, file I/O

Status
Not open for further replies.

ahmad_abdulghany

Advanced Member level 4
Advanced Member level 4
Joined
Apr 12, 2005
Messages
1,206
Helped
102
Reputation
206
Reaction score
22
Trophy points
1,318
Location
San Jose, California, USA
Activity points
11,769
Hi,

I have two basic questions:

1. How can I match special characters using regular expression?

2. I have written this piece of code to find all occurrence of a rule
name (e.g. rule ) in a file containing a lot of rules, each have the
form: rule_name { body of the rule containing many special characters
(like @, //, ... ) and numbers }

set file "test.rul"
set rule_name_list ""
#if { [file exists $file] && [file readable $file] } {
set fd [open $file RDONLY]
while { ! [eof $fd] } {
gets $fd line
set line [string trim $line]

if { [string match *\{*\} $line] } {
set rule_name [lindex $line 0]
lappend rule_name_list $rule_name
}
}
close $fd
#}

It gives errors !!

I don't know what to do to fix:
1. Check if file exists and is readable
2. Match and append the required pattern to the rules_list

Anybody advice to do it?

thanks and best regards,
Ahmad
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top