php - regex that matches the text between the tags like p a, br -
i need regex matches text between tags p a, br: albert einstein, division head, princeton member of executive committee of princeton
i have pattern (preg_match_all)
$pattern="/<\s*a[^>]++>(.*?)<\s*\/\s*a\s*>/"
;
but gives me text inside hrefs,
any hints? // heres sample source
<p> <a href="file.pdf" target="_blank"><b>albert einstein</b></a><br> division head, princeton<br> member of executive committee of princeton<br> </p>
using dom parser can values inside tags want :
<?php $html='<p> <a href="file.pdf" target="_blank"><b>albert einstein</b></a><br> division head, princeton<br> member of executive committee of princeton<br> </p>'; $dom = new domdocument; $dom->loadhtml($html); echo "[".$dom->getelementsbytagname('p')->item(0)->nodevalue."]";
you can change tag value , see .
demo here : https://eval.in/139559
just changing value p
b
, can text inside b
tag , i.e. [albert einstein]
Comments
Post a Comment