Jump to content

Question about CPU usage by preg_match


etrader

Recommended Posts

I have searched a lot but no information about this aspect. I wonder how much heavy is the process of getting parts of a webpage by preg_match?

 

But my question is that which of these options are in favor of lighter CPU process:

 

1. getting each item between specified tags by a preg_match

or

2. First getting the content between <body>, then processing by php tools such as preg_match (again), explode, etc.

 

Thanks for considering this unusual question  :D

Link to comment
https://forums.phpfreaks.com/topic/232279-question-about-cpu-usage-by-preg_match/
Share on other sites

Hi,

 

you should query in the minimal content u can. If your parts in anywhere in the body get the entiry body and run the search loop in it. If those in a div get that div... Anyway regexp is not a fast method. You can use str pos in a loop, with the handy offset paramterer.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.