kejo Posted January 29, 2008 Share Posted January 29, 2008 hello, hope you can help me. i need to get the value: 56.64 out of this string Uploaded:</font> <font color="#cccccc">56.64 GB i tried many and many, but wasnt able to find a good one please help me. thanks, this forum is full of good people! Link to comment https://forums.phpfreaks.com/topic/88477-who-can-help-finding-a-good-regex-to-work/ Share on other sites More sharing options...
effigy Posted January 29, 2008 Share Posted January 29, 2008 What did you try, and why do you think they failed? <pre> <?php $data = 'Uploaded:</font> <font color="#cccccc">56.64 GB'; preg_match('%(?<=Uploaded:</font> <font color="#cccccc">)([\d.]+)%', $data, $matches); print_r($matches); ?> <pre> Link to comment https://forums.phpfreaks.com/topic/88477-who-can-help-finding-a-good-regex-to-work/#findComment-452900 Share on other sites More sharing options...
kejo Posted January 29, 2008 Author Share Posted January 29, 2008 thanks mate! how come it doesnt work if the $data is an extracted webpage ? $data = file_get_contents('http://www.site.com'); Link to comment https://forums.phpfreaks.com/topic/88477-who-can-help-finding-a-good-regex-to-work/#findComment-452910 Share on other sites More sharing options...
laffin Posted January 29, 2008 Share Posted January 29, 2008 i wudda opted for sumfin like preg_match("@Uploaded:(?:<.*>)(\d{1,}.\d{2}) ([bGMTK]{2})@i",$data,$matches) Link to comment https://forums.phpfreaks.com/topic/88477-who-can-help-finding-a-good-regex-to-work/#findComment-452941 Share on other sites More sharing options...
kejo Posted January 29, 2008 Author Share Posted January 29, 2008 ok guys i got what the problem is: the site i get the value from needs to be logged in: how can i do this in php? i need to access the page and get the value trhu the script... Link to comment https://forums.phpfreaks.com/topic/88477-who-can-help-finding-a-good-regex-to-work/#findComment-452951 Share on other sites More sharing options...
laffin Posted January 30, 2008 Share Posted January 30, 2008 depends on the authentication method cookies or https for https ya can put the username/pw on the url string https://site.com@user:pw/path/ I believe the format is for cookies ya will prolly opt for using curl (as fopen wud be a lot of code) [http://www.weberdev.com/get_example-4555.html]using curl with cookies example[/url] Link to comment https://forums.phpfreaks.com/topic/88477-who-can-help-finding-a-good-regex-to-work/#findComment-453219 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.