Link to home
Start Free TrialLog in
Avatar of tindavid
tindavid

asked on

Extract multiple value with delimiters from a string

Hi All,

I have a simple perl script that can extract the source code from a webpage like below:

#!/usr/local/bin/perl

use WWW::Mechanize;

my $page = WWW::Mechanize->new();
#$page->get("http://www.hkjc.com/english/racing/selecthorsebychar.asp?ordertype=B");
$page->get("http://www.hkjc.com/chinese/racing/selecthorsebychar.asp?ordertype=2");
my $data = $page->res()->content();
print $data;

What actually in the $data is a single string that contain some data that are useful for me:

What I need to is extract the information of

HorseNo=T108
HorseNo=T252
.......


Please send me your revised perl code for the task.

Thank you,

David
Avatar of arnold
arnold
Flag of United States of America image

Need to see the entire string
To see whether there is a separator, is the sata as it is represented one entry per line?
As arnold said, you don't provide us with enough $data to construct a good regex (or other means of extraction).
Avatar of tindavid
tindavid

ASKER

I don't understand, you mean the data from get() is not good enough for program to extract data after a pattern of "
horse.asp?HorseNo", all I need is the T322, T323, T340 .....


If you cut and paste the perl code and run it you should see the output ,  the value in the data is come from the get("http://www.hkjc.com/chinese/racing/selecthorsebychar.asp?ordertype=2");


 what I want is to continue the code :  print $data

to search $data to extract all information from the $data

.......class=table_Text><a href="horse.asp?HorseNo=T322" ......
.......class=table_Text><a href="horse.asp?HorseNo=T333" ......
.......class=table_Text><a href="horse.asp?HorseNo=T340"........
ASKER CERTIFIED SOLUTION
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial