&acute breakout?

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
slash85
Forum Newbie
Posts: 18
Joined: Fri Feb 03, 2006 12:02 pm

&acute breakout?

Post 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.
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: &acute breakout?

Post 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.
slash85
Forum Newbie
Posts: 18
Joined: Fri Feb 03, 2006 12:02 pm

Re: &acute breakout?

Post by slash85 »

Hhhmmmm,

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

Thanks,
Slash.
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: &acute breakout?

Post 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.
Post Reply