Answer the question
In order to leave comments, you need to log in
How to fix regex?
$text = '<li class=" default-news-list">
<a href="news/showNews.do?sud_ponoviv_na_posadi_ekszastupnika_nachalnika_golovnogo_slidchogo_upravlinnya_natspolitsiyi&objectId=1388205" >
<div class="time">13:31</div>
<div class="news-title">
Суд поновив на посаді екс-заступника начальника головного слідчого управління Нацполіції
</div>
</a>
</li>';
preg_match('#<li class=" default-news-list">(.*?)</li>#', $text, $var);
var_dump($var);
Answer the question
In order to leave comments, you need to log in
preg_match('#(.*?)#s', $text, $var);
add the s modifier
php.net/manual/ru/reference.pcre.pattern.modifiers.php
s (PCRE_DOTALL)
If this modifier is used, the "dot" metacharacter in the pattern matches all characters, including newlines. Without it - everything, except for newlines. This modifier is equivalent to /s in Perl. A negated character class, such as [^a], always matches a newline, regardless of the presence of this modifier.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question