Page 1 of 1

Strange character returned with regex.

Posted: Wed Aug 03, 2011 12:19 pm
by social_experiment
My regular expression looks for this specific value inside an html document:

Code: Select all

$pattern = '/<span id="temp">.+<\/span>/';
// returns 16°C.
Html to find

Code: Select all

<span id="temp">16°C</span>
It returns something else though : 16°C.

I've tried using another pattern (+\d°C) but this doesn't return anything. Is there something that i am missing in terms of the original regular expression?

Re: Strange character returned with regex.

Posted: Wed Aug 03, 2011 11:39 pm
by Weirdan
are you sure your output encoding matches the encoding of the string you're running your regexp on? If it's utf-8 you might have better luck specifying your regexp as utf (/<span id="temp">.+<\/span>/u)

Re: Strange character returned with regex.

Posted: Thu Aug 04, 2011 5:42 am
by social_experiment
Thanks for the help, the problem was that the charset wasn't specified on the page displaying the information.