In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use the preg match regular expression function in PHP. It has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
The preg_match() function is used to match regular expressions and returns 1 if successful, or 0 otherwise.
preg_match() stops matching after one successful match. If you want to match all the results, you need to use the preg_match_all() function.
Grammar:
preg_match (pattern , subject, matches) Parameter description pattern Regular expression subject Objects to be matched matches Optional, array storing matching results
Examples:
This instance matches capital letters followed by. A string of characters with spaces can only match up to J. Because preg_match() will stop matching after one successful match, and will not match again.
Output:
Array ( [0] => J. )
The following is an introduction to the preg_match string length problem
preg_match regular extraction target content, dead or alive problems, code measured dead.
Later, I suspected that PHP's preg_match has a string length limit, and sure enough, I found that the value of "pcre.backtrack_limit " is only set to 100000 by default.
Solution:
ini_set('pcre.backtrack_limit', 999999999);
Note: This parameter is available after PHP 5.2.0.
Pcre. recurrence_limit
pcre. recurrence_limit is the recursion limit of PCRE, which, if set to a large value, consumes all available stacks of processes and eventually causes PHP to crash.
You can also restrict it by modifying the configuration:
ini_set('pcre.recursion_limit', 99999);
In actual project applications, it is also best to set the memory limit: ini_set ('memory_limit','64 M'); , so that it is more stable.
Thank you for reading this article carefully. I hope that Xiaobian will share the article "How to use preg match regular expression function in PHP". This article is helpful to everyone. At the same time, I hope that everyone will support it a lot. Pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.