im using regular expression to match some data in a web page—
http://www.mobme.in/people
the regular expression—
/people_files[^>]*?.jpg/
this works in ruby but howver it does not result in any matches in php
can someone explain to me why?
im using regular expression to match some data in a web page—
http://www.mobme.in/people
the regular expression—
/people_files[^>]*?.jpg/
this works in ruby but howver it does not result in any matches in php
can someone explain to me why?
Hi there I would personally have the string as the following in a PHP match:
[php]preg_match(’#/people_files([^>]*)?/#’,$string);[/php]
Try that and let me know if it works out.
i tried the code to no avail it returns an empty array
let me detail the code–
php code-
$homepage = file_get_contents(‘http://www.mobme.in/people’);
preg_match_all(’#/people_files([^>]*)?/#’,$homepage,$k_arr);
print_r($k_arr);
gives empty arrays
ruby code-
ruby-1.9.2-p180 :008 > str.scan(/people_files[^>]*?.jpg/)
=> [“people_files/sanjaythumb-w160h160.jpg”, “people_files/sanjaythumb-w160h160.jpg”, “people_files/sonythumb-w160h160.jpg”, “people_files/sonythumb-w160h160.jpg”, “people_files/vivekthumb-w160h160.jpg”, “people_files/vivekthumb-w160h160.jpg”, “people_files/vishnuthumb-w160h160.jpg”, “people_files/vishnuthumb-w160h160.jpg”, “people_files/ash01-w160h160.jpg”, “people_files/ash01-w160h160.jpg”, “people_files/manuthumb-w160h160.jpg”, “people_files/manuthumb-w160h160.jpg”, “people_files/lishoy-w160h160.jpg”, “people_files/lishoy-w160h160.jpg”, “people_files/anoop-w160h160.jpg”, “people_files/anoop-w160h160.jpg”, “people_files/sherinthumb-w160h160.jpg”, “people_files/sherinthumb-w160h160.jpg”, “people_files/nanduthumb-w160h160.jpg”, “people_files/nanduthumb-w160h160.jpg”]
it gives result in ruby i need to know what to modify so the code works in php…
is regexp different from ruby in php?
Just so you know, don’t know if I’m missing something here. But the source of that page shows that the image paths are in this format:
/perch/resources/sanjaythumb-w160h160.jpg
Rather than the one your regex suggests
the urls have been changed
it used to be /people_file/*.jpg
got a local copy…
anyway on the update page
preg_match_all(’/perch[^>]*?.jpg/’,$homepage,$k_arr);
the results get matched
local copy–
http://pastebin.com/eZDM1AWN
with the original regex could not get it to work … can get result in recent version… wierd
nevermind seems to have fixed it with the regex… restarted my comp and it works :(… thnx for the help and time
Haha, strange. No worries, glad to have helped!