Page 1 of 1

find the closest number to symbol

Posted: Fri Jun 12, 2009 3:28 am
by avukadomusic
hi I need a code to find the closest number to the symbol $ in a given url's source code
for example

http://www.somesite/somepage
the source code of this page has some prices:

code... code... code...code... code... code...
160 $
code... code... code...code... code... code...
210$
code... code... code...code... code... code...
ets'

I want a code that would return just the first number that is near the $ sign

thanks

Re: find the closest number to symbol

Posted: Fri Jun 12, 2009 9:40 am
by pickle
A regex might work

(untested):

Code: Select all

$source_code = 'source code of page';
preg_match('/\w(\d*).*?\$/',$source_code,$matches);

Re: find the closest number to symbol

Posted: Mon Jun 15, 2009 6:10 am
by avukadomusic
hi , it didn't work
maybe I was not explaining good

I think it is like screen scraping
the data I need in an external website's source code
I want the program to be given a page's address
and it would search the page's source code and giving me the closest number to a given sign like $
the first time $ shows up.