Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7513279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:08:01+00:00 2026-05-30T00:08:01+00:00

Here is my regex: $table_pattern = /<TABLE.*?>(.*?)<\/TABLE>/is; Like the title says, it works in

  • 0

Here is my regex:

$table_pattern = "/<TABLE.*?>(.*?)<\/TABLE>/is";

Like the title says, it works in 5.1 and 5.3, but not 5.2. I’m using it in this preg_match:

preg_match_all($table_pattern, $page_content, $table_content);

$table_content is NULL on 5.2, but populated on 5.1 and 5.3. Any idea as to why?

Additional details:

$car_count = 47; //How many cars are currently online
$page_content = file_get_contents('http://www.site.com/temps/inventory.cfm?ChangeItems='.$car_count);; // What page will be parsed
$page_start = 10277; //Where the parsing should start

$page_content = substr($page_content, $page_start); //Removes all of the text above the table we need
$table_pattern = "/\<TABLE.*?\>(.*?)\<\/TABLE\>/is";
preg_match_all($table_pattern, $page_content, $table_content); //Finds all tables inside of $page_content and fills the $table_content array
$final_content = $table_content[0][0]; //Setting the first table, which is the match we need, to $table

$final_content is coming up as NULL. Obviously there is more happening below this in my code but it’s irrelevant.

I solved my own problem by – wait for it – NOT using RegEx! But really, I initially thought this would be much faster than dealing with the PHP Simple HTML Parser, but it wasn’t. But I am still curious as to why this will not work in certain versions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:08:03+00:00Added an answer on May 30, 2026 at 12:08 am

    It is possible to parse XML in PHP with recursive regex, but please use an XML library instead of regex. It’s much cleaner and easier…

    (Your code fails if you have nested “tables” in your XML…)

    The PCRE is developed by another team than the php, and the older versions have bugs. Maybe there is a bug in the PCRE passed to the php 5.2 which is fixed by the later versions.

    Another explanation could be, that you have unicode xml, and you didn’t use the “u” flag.

    By me it works on php 5.2.17. Which version do you have?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not even sure if this is possible or not, but here's what I'd
I’m trying to validate input by using egrep and regex.Here is the line from
I'm trying to get all words inside a string using Boost::regex in C++. Here's
I would like to extract some text from an html file using Regex. I
I'd like to split a string in MySQL using a regex delimiter. Is there
Here's a regex for validating emails - \S+@\S+\.\S+ , I didn't write it. I'm
here is a regex i got from: a blog i can't link to because
In need of a regex master here! <img src=\img.gif style=float:left; border:0 /> <img src=\img.gif
Here's a basic regex technique that I've never managed to remember. Let's say I'm
I've managed to find the Regex to get almost the result I want here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.