View Full Version : Expression problem
dizyn
Aug 12th 2008, 12:35 am
Hi
I want to fetch 26 out of this using express. I used following code but failed.
$data = '<span style="text-transform: capitalize;">cloudy</span> 26<abbr title="Temperature in degrees Celsius">°C</abbr>';
$pattern = '/</span> (.*)<abbr title/msU';
preg_match_all($pattern, $data, $matche1);
thanks
dizyn
nico_swd
Aug 12th 2008, 12:41 am
You have to escape the slash inside the </span>.
beacon
Aug 12th 2008, 12:47 am
Hi
I want to fetch 26 out of this using express. I used following code but failed.
$data = '<span style="text-transform: capitalize;">cloudy</span> 26<abbr title="Temperature in degrees Celsius">°C</abbr>';
$pattern = '/</span> (.*)<abbr title/msU';
preg_match_all($pattern, $data, $matche1);
thanks
dizyn
Need escape /
This work:
$data = '<span style="text-transform: capitalize;">cloudy</span> 26<abbr title="Temperature in degrees Celsius">°C</abbr>';
$pattern = '/<\/span> (.*)<abbr title/msU';
preg_match_all($pattern, $data, $matche1);
print_r($matche1);
nabil_kadimi
Aug 12th 2008, 12:53 am
$data = '<span style="text-transform: capitalize;">cloudy</span> 26<abbr title="Temperature in degrees Celsius">°C</abbr>';
$pattern = '#[\d]+#';
preg_match_all ( $pattern, $data, $matche1);
echo '<pre>';
var_dump($matche1);
echo '</pre>';
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.