如何使用正则表达式从字符串中提取div的内容

时间:2011-12-16 06:51:10

标签: php regex

  

可能重复:
  regex php: find everything in div

我有像

这样的字符串
$str= 'hello asd asd 
<div class="name">Sunil</div>' asdasd
asdasdasd
asdasdasdasd;

我想获得div名称的内容。 (意思是我想得到Sunil)使用reg ex ..

请帮助我。

1 个答案:

答案 0 :(得分:0)

您无法使用正则表达式进行递归搜索,因为它无法表达递归。这就是人们编写解析器的原因。

我相信你要找的是http://simplehtmldom.sourceforge.net/