Hi - I'm working on a script to retrieve news headlines from a site - I use string match to identify the line in the html that has the info I want.
Normally when I do this, it gets the first line of the match, but in this case it's getting the last line (as there are many) at the bottom of the page...is there any way around this?
I don't see how this is a string match problem. string match will not tell you where the match is, so the error must be in some other part of your code (obviously).
foreach line [split $body \n] {
if {[string match "*storylink*" $line]} {
and instead of getting the first line 'storylink' is in, it's getting the last. I'm not doing anything else to it except filtering the bits of the line I don't need.
break exits the loop, you should add the break inside the if-statement since you already found your match in the first line. Of course, add the break after the needed statements inside the if-statement (in your case, after the regexp).