Posted by BKDotCom on 12/09/06 16:28
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
Navigation:
[Reply to this message]
|