In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what is the regular expression processing function based on perl in PHP. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Commonly used regular expression processing functions.
1the preglossmatch () function.
The function preg_match () performs a regular expression match defined as follows:
Int preg_match (string $pattern, string $subject [, array & $matches [, int $flags = 0 [, int $offset = 0])
It is actually searching for parts of the subject that match pattern to save in the array matches. Take a look at the example:
In the above example, we use the pattern modifier e so that the strtoupper () function can be parsed as a string, which is what the pattern modifier e does! The parameters ${1} and\ 2 are submode 1 and submode 2, respectively. The purpose of the above example is to replace the matching subpatterns php and mysql in the string $string with uppercase letters!
4the prestressed split () function.
Preg_split executes a regular expression to separate strings. It is defined as follows:
Array preg_split (string $pattern, string $subject [, int $limit =-1 [, int $flags = 0]])
In fact, it splits the subject according to pattern and returns the split array. Among them, limit will limit the separation of the resulting substrings to a maximum of limit, and the last substring returned will contain all the remaining parts. A value of-1, 0 or null means "unlimited".
Let's look at an example:
In the above example, we used the constant PREG_SPLIT_DELIM_CAPTURE to set the return result to include submodes (if set to PREG_SPLIT_NO_EMPTY,preg_split () to enter the non-empty part after the return is separated). If we remove the parentheses from the regular expression in the above example, the results no longer include the two successful matching subpatterns, php and mysql.
We are done with the commonly used regular expression processing functions, and the examples in this section may be more difficult, but I hope you will try it seriously and experience it. In the following regular expression application part, we will often use regular expressions to handle functions.
This is the end of this article on "what is the regular expression processing function based on perl in PHP". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.