-1

Here is my regex101 example which works : https://regex101.com/r/fE6rO9/2 (you have to wait a few secondes because it's big )

here is my PHP

    $content = htmlentities($contentCode);
    /* correct echo when i copy paste it into regex101 */
    echo $content;

    // copy past from regex101
    $re = "/<\\/form><table class=\"forumline\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">(.*)<\\/table><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">/"; 

    preg_match($re, $content, $matches);

    var_dump($matches);

but when i run it, it echoes :

array (size=0)
  empty

Any idea what the problem is ?

This is the regex taken appart :

"/<\\/form><table class=\"forumline\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">(.*)<\\/table><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">/"; 
Bidoubiwa
  • 910
  • 2
  • 12
  • 25

1 Answers1

2

I've tested your regex and it seems to work if you remove

$content = htmlentities($contentCode);

simply use:

$content = $contentCode;

Notes:

  1. Please make sure you read You can't parse [X]HTML with regex
  2. Some alternatives to regex are DOMDocument or simplehtmldom
Community
  • 1
  • 1
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
  • Haha oke ! I will not use Regex to parse HTML. I know how to retrieve all the information with jquery but since i'm using PHP is there another way of retrieving the information ? – Bidoubiwa Apr 25 '16 at 23:50
  • 1
    You can use php [DOMDocument](https://secure.php.net/manual/en/class.domdocument.php) or [simplehtmldom](http://simplehtmldom.sourceforge.net/) – Pedro Lobito Apr 25 '16 at 23:53
  • Oh ok that's pretty powerfull to get every information of every node. But When i just loadHTML with $contentCode I recieve a lot of errors. With my regex i just took the part of the html i needed and with the DOMdocument i can access each row very easely. – Bidoubiwa Apr 26 '16 at 00:55