The string length problem of preg_match function regular matching in PHP _php tutorial

Source: Internet
Author: User

The string length problem of regular matching of preg_match function in PHP


This article mainly introduces PHP Preg_match function Regular matching string length problem, if you also encountered Preg_match regular extract content is always blank or not extracted, it may be encountered this problem, the need for friends can refer to the next

Project, using Preg_match to extract the target content, dead and alive there is a problem, the code measured very much.

Later suspected that PHP Preg_match has a string length limit, sure enough, found that the value of "Pcre.backtrack_limit" is set by default only 100000.

Workaround: Ini_set (' Pcre.backtrack_limit ', 999999999);

Note: This parameter is available after PHP 5.2.0 version.

Also talk about: Pcre.recursion_limit

Pcre.recursion_limit is the recursive limit of pcre, which, if set to a large value, consumes the available stacks of all processes and eventually causes PHP to crash.

can also be limited by modifying the configuration: Ini_set (' Pcre.recursion_limit ', 99999);

In the actual project application, it is best to also set the memory limit: Ini_set (' memory_limit ', ' 64M '); , so it's more secure.

http://www.bkjia.com/PHPjc/1007650.html www.bkjia.com true http://www.bkjia.com/PHPjc/1007650.html techarticle The string length problem of regular matching of preg_match function in PHP This article mainly introduces the string length problem of preg_match function regular matching in PHP, if you also encounter the Preg_match regular ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.