In php, the preg_match () function is a common function used to execute regular expressions. This article describes the operation example of the PHPpregmatch regular expression function. For more information, see the preg_match () function in php. Regular expressions are used in almost all programming languages. this example introduces the application of the regular expression preg_match function in php.
The preg_match () function is used for regular expression matching. if the regular expression matches successfully, 1 is returned. otherwise, 0 is returned.
After a successful preg_match () match, the match is stopped. to match all the results, use the preg_match_all () function.
Syntax:
preg_match (pattern , subject, matches)
This instance matches strings with. and spaces after uppercase letters, and can only match J., because after a successful preg_match () match, the match will be stopped and will not be matched later.
Output result:
Array ([0] => J .)
The following describes the length of the preg_match string.
Preg_match: the regular expression extracts the target content. if there is a problem with whether the content is live or not, the code is dead.
Later, I suspect that PHP's preg_match has a string length limit, and found that the value of "pcre. backtrack_limit" is set to only 100000 by default.
Solution:
ini_set('pcre.backtrack_limit', 999999999);
Note: this parameter is available after php 5.2.0.
For more information, see pcre. recursion_limit.
Pcre. recursion_limit is the recursive limitation of PCRE. if this item is set to a large value, it will consume the available stacks of all processes and eventually cause PHP to crash.
You can also modify the configuration to limit the following:
Ini_set ('pcre. recursion_limit ', 99999 );
In actual project applications, it is best to set the memory limit: ini_set ('memory _ limit ', '64m');, which makes it safer.
For more articles on operating instances of PHP preg match regular expression functions, refer to PHP Chinese network!