Reply to Re: expression problem

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация