Page 1 of 1

&acute breakout?

Posted: Thu Apr 23, 2009 2:18 pm
by slash85
Hi All,

Has any one seen this before?

When i perform a preg_match_all on a html page that contains ´ it breaks out my pregmatch?

eg the html file contains (with the usual html tags and stuff):

drS_name='Panthers Run'
drS_name='Jack´s Lad'
drS_name='Red Jester'

What i'm matching is (?<=drS_name=.).+[a-z] which should return:

Panthers Run
Jack&acute;s Lad
Red Jester

but because of the html &acute; its breaking the match out and only returning:

Jack'


Any Ideas anyone?

Thanks,
Slash.

Re: &acute breakout?

Posted: Thu Apr 23, 2009 2:47 pm
by prometheuzz
I get exactly what you expect:

Code: Select all

<?php
 
$text = "drS_name='Panthers Run'
drS_name='Jack&acute;s Lad'
drS_name='Red Jester'";
 
preg_match_all('/(?<=drS_name=.).+[a-z]/', $text, $matches);
 
print_r($matches);
 
/* output:
Array
(
    [0] => Array
        (
            [0] => Panthers Run
            [1] => Jack&acute;s Lad
            [2] => Red Jester
        )
 
)
*/
?>
So, there's something wrong with your regex engine, or, more likely, you're doing something wrong or are not getting the string you had expected.

Re: &acute breakout?

Posted: Fri Apr 24, 2009 7:18 am
by slash85
Hhhmmmm,

Thanks for the reply. I'll try upgrading my version of php see if that helps.

Thanks,
Slash.

Re: &acute breakout?

Posted: Fri Apr 24, 2009 7:57 am
by prometheuzz
slash85 wrote:Hhhmmmm,

Thanks for the reply. I'll try upgrading my version of php see if that helps.

Thanks,
Slash.
I don't think it's your PHP version.
Before making the match, try echo-ing the text you're matching your pattern against. Most likely the text is something other than you expected.