1

I'm trying to extract some information out of a website.

My problem is that I need to extract text that is like this:

<p class="review"> "Desired text3" </p>

How to get the text that is inside the quotation marks " .... "?

Actually I've tried this but it wont work at all!

preg_match_all('|<p class=\"adress\">(.*)<\/p>|',$data,$text);

Any ideas?

Ivan Olshansky
  • 889
  • 2
  • 17
  • 23
Morris
  • 21
  • 3
  • HTML and regex are not good friends. Use a parser, it is simpler, faster and much more maintainable. See: http://php.net/manual/en/class.domdocument.php – Toto Mar 06 '19 at 09:58

1 Answers1

0
<?php
$data = '<p class="review"> "Desired text3" </p>';
preg_match_all('|>\s*"(.*)"\s*<\/|',$data,$text);
var_dump($text[1][0]);

Demo

sheng
  • 1
  • 2