|
Posted by emmerink on 12/09/06 17:24
BKDotCom schreef:
> emmerink@gmail.com wrote:
> > $xml = "tekst <title> twee </title>\n drie </tr> vier </td>";
> >
> > $a_sSubject = trim($xml);
> >
> > $a_sStart = '<title>';$a_sEnd = '<\/tr>';
> > $pattern = '/'. $a_sStart .'(.*?)'. $a_sEnd .'/';
> > preg_match_all($pattern, $a_sSubject, $result);
> >
> > print_r($result);
> >
> > Any idea why there is no content in the result?
> > (expected to find the content in between <title> en </tr>)
>
> pay no attention to naixn. :) The ? character != "ignore" it means
> "not greedy"
> Your "problem" is that your search string contains a linebreak.
> you need to add the "s" modifier to your expression so that the "."
> matches the "\n"
> http://us2.php.net/manual/en/reference.pcre.pattern.modifiers.php
> $pattern = '/'. $a_sStart .'(.*?)'. $a_sEnd .'/s'; // should be good
Thanks, that did it. Although naixn noticed the modifier, you were
much more to the point (which made it more useful in this quite
confusing regexp notations).
Navigation:
[Reply to this message]
|