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.

parse next line

Old posts that have not been replied to for several years.
Locked
K
Koepi.Bln

parse next line

Post by Koepi.Bln »

Code: Select all

foreach line [split $buffer \n] {
      if {[string match "*VfL Wolfsburg*" $line]} {
      regexp {\"([^<]*)\" BORDER} $line garb name
How can i make, that he parse "name" from the line after he found "VfL Wolfsburg" and not from the same line?

Sorry for my bad english, i'am german ;).

greets
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

could u explain closer what it is you are trying to reach ?
XplaiN but think of me as stupid
K
Koepi.Bln

Post by Koepi.Bln »

ok, i try.

i like to parse a html file. I search the file for "*VfL Wolfsburg*". In the line after "*VfL Wolfsburg*" is the string i want to grab.
The string want tu grab is much often in the html file, so i must locate "*VfL Wolfsburg*" one line bevore.

ok?
s
spock
Master
Posts: 319
Joined: Thu Dec 12, 2002 8:40 pm

Post by spock »

Code: Select all

  set data [split [read $fp] "\n"]
  if {[set a [lsearch -glob $data "*VfL Wolfsburg*"]] != -1} { puts "[lindex $data [expr $a + 1]]" }
  close $fp
photon?
K
Koepi.Bln

Post by Koepi.Bln »

first times thx for your answer, but i couldt'n insert it in my script. My tcl knowledge is very limited.

this script should post the table from the german football league.

this is a part from the source of the page:

Code: Select all

<td nowrap valign="top"><a href="/vereine/vflwolfsburg/2005/" title="Portrait und Saisonverlauf von VfL Wolfsburg">VfL Wolfsburg</a></td>
<td align="right" valign="top">7 </td>
<td align="right" valign="top">6</td>
<td align="right" valign="top">0</td>
<td align="right" valign="top">1</td>
<td align="center" valign="top"> 13:6  </td>
<td align="right" valign="top">+7</td>
<td align="right" valign="top">18</td>
</tr>
the link is http://www.fussballdaten.de/bundesliga/

i have change all &nbsp with " " with regsub -all { } $buffer " " buffer

can you give me a example how a parse the data after
"<td nowrap valign="top"><a href="/vereine/vflwolfsburg/2005/" title="Portrait und Saisonverlauf von VfL Wolfsburg">VfL Wolfsburg</a></td>" for every place in the table?

i hope you understand what i mean.

greets Koepi
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

if its a continues string maybe look at string map {} in tcl man otherwize if ur trying to strip html tags check the forum i just asked teh same question ;) and its explained with examples
to parse the next line u could maybe do this

Code: Select all

set rf [open file]; or you could get it directly from ur socket.. 
while {![eof $rf]} {
  gets  $rf x
  if {![string match -nocase "urstring" $x]} {
     continue
  }
  gets $rf x 
  puts $x
}
close $rf
i think .. at least thats what i understand from tcl man .. could be wrong to ..
XplaiN but think of me as stupid
Locked