troubleshooting Question

PHP pcre Regular Expression max characters? -- regex, preg_match

Avatar of seanhess
seanhess asked on
PHPRegular Expressions
5 Comments1 Solution1382 ViewsLast Modified:
PHP's preg_match seems to be failing when the subject has too many characters in it.  

This is my expression::
   preg_match('/(.*<div id="storeArea">\s*)(.*)(\s*<\/div>\s*<!--POST-BODY-START-->.*)/si', $subject, $regs)

And here is the subject
<html>
<body>
<div id="storeArea">
<div>aaa ... </div>
<div>aaa ... </div>
<div>aaa ... </div>
</div>
<!--POST-BODY-START-->
<!--POST-BODY-END-->
      </body>
</html>

It will match fine on that, but if the aaa .... is made HUGELY long, it won't match any more.  I tested it with 80,000 a's in each line.  If there was only one line (div tag) of A's, it would match, but it wouldn't match 3 lines of a's.

Is there a character limit to preg_match?  Why would it behave like this?  Can I fix the regular expression?

Thanks!

We're sending info to a php script.  It is supposed to match a regular expression against the data.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros