ahmad_abdulghany
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
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