Using glob to search for wildcard numbers such as FIBRENNNN where NNNN=1235 for example
From: Jonathan Smoker (jonathan_smoker_at_hotmail.com)
Date: 12/29/03
- Next message: Derk Gwen: "Re: last 20 lines of a file on WinDoze ?"
- Previous message: David Moerman: "Re: Expect problem"
- Next in thread: Derk Gwen: "Re: Using glob to search for wildcard numbers such as FIBRENNNN where NNNN=1235 for example"
- Reply: Derk Gwen: "Re: Using glob to search for wildcard numbers such as FIBRENNNN where NNNN=1235 for example"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Dec 2003 09:11:03 -0800
Hello,
Sorry, this is an easy tcl question from someone just starting. I am
using tcl to search through a file, looking for the following type of
strings;
FIBRE1149
FIBRE2052
FIBRE1235
-where 'FIBRE' is always the same, just the four digits of the
following number change. The manual says that I can just use 'glob'
with the same arguments that 'string match' also uses, viz something
like [0-9].
My script works fine if I just use FIBRE (as in the code segment shown
at the bottom), but I can't seem to get the syntax right to make it
search for FIBRENNNN. Could anyone please advise me what I am doing
wrong?. I have tried the following variants;
set key_fibre_N [lsearch -glob FIBRE[0-9][0-9][0-9][0-9] $key] - wrong
syntax
set key_fibre_N [lsearch -glob FIBRE[????] $key] - wrong syntax
set key_fibre_N [lsearch -glob [FIBRE????] $key] - wrong syntax
set key_fibre_N [lsearch -glob FIBRE???? $key] -
syntax OK but I think looks for FIBRE???? which is no good
set key_fibre_N [lsearch -glob {FIBRE[0-9][0-9][0-9][0-9]} $key] -
syntax OK but does not find FIBRE1234
set key_fibre_N [lsearch -glob {[FIBRE][0-9][0-9][0-9][0-9]} $key] -
syntax OK but does not find FIBRE1234
Code segment that I have written;
while {![eof $fidin]} {
set inline [gets $fidin]
set inline_split [split $inline]
foreach key [split $inline] {
set count_0 [expr $count_0 + 1]
set count_1 [expr $count_0 + 1]
set key_fibre_N [lsearch -glob FIBRE $key]
puts $key_fibre_N
puts $key
}
}
close $fidin
close $fidout
Thanks!,
Jonathan.
- Next message: Derk Gwen: "Re: last 20 lines of a file on WinDoze ?"
- Previous message: David Moerman: "Re: Expect problem"
- Next in thread: Derk Gwen: "Re: Using glob to search for wildcard numbers such as FIBRENNNN where NNNN=1235 for example"
- Reply: Derk Gwen: "Re: Using glob to search for wildcard numbers such as FIBRENNNN where NNNN=1235 for example"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|