line.find ("string with regexp" ,0);

Hi

For my program, I need to retrieve a value from a html file (screen scraping).

I have to get the value of "9,949.81"
 
Dow</a></td><td><span class="streaming-datum" id="yfs_l10_^dji">9,949.81</span></td><td class="ticker_down"><span class="streaming-datum" id="yfs_c10_^dji">


this is my code to get the value:
1
2
3
4
idlocation = line.find ("id=\"yfs_l10_^dji\">", 0);
                rightlocation = line.find ("</span></td><td class=\"ticker_down\"><span class=\"streaming-datum\" id=\"yfs_c10_^dji\">", 0);
                Val_location_start = idlocation + 18;
                Val_length = rightlocation - Val_location_start;


However, the line ("ticker_down\") is not always the same and i'm thinking of using regular expression so that my code could work.

i tried this (with a * ) but it could not work:
 
rightlocation = line.find ("</span></td><td class=*><span class=\"streaming-datum\" id=\"yfs_c10_^dji\">", 0);


Please advise any possible method to retrieve the value.

Thanks alot

Last edited on
You need to use a regular expression library for that. string.find() does literal finds.
Topic archived. No new replies allowed.