In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use regular expressions. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
The problem is, in a certain case, you have to give: http://jb51.net?a=1
The append parameter of this kind of url address is changed to: http://jb51.net?a=1&b=2
But how do you know that the same parameter name already exists, for example, in this case: http://jb51.net?a=1&a=2
There won't be any big mistakes in this, but the address bar looks bad. What are we going to do? Use the regular solution (I originally wanted to use php's string processing to solve the problem, but then I thought that if I wanted to learn the regular, I would use the regular to do it.)
The following is the background processing method I used to return to the previous page
Function _ goBack ($msg=null,$get=array ()) {
$url = $_ SESSION ['BACKURL']
If ($getgun array ())
Foreach ($get as $k = > $g) {
$url.='&'.$k.'='.$g;// appends all parameters to be appended first, regardless of whether they are repeated or not
If (count (explode ("& {$k} =", $url) > 2) {/ / if the current url string is split in the format "& a =", more than two split arrays are found, indicating that the string has duplicate parameters.
$url=preg_replace ("/ {$k} = [a-zA-Z0-9] * & /",'', $url); / / regular replacement all "& axix" is empty
}
}
Unset ($_ SESSION ['BACKURL'])
$this- > alert ($msg,$url)
}
A simple explanation:
"/ {$k} = [a-zA-Z0-9] * & /" if we assume $k = "a", that is, "/ a = [a-zA-Z0-9] * & /"
I don't know if I understand it correctly, but it actually means that the match starts with "a =", followed by any combination of numbers and letters ([a-zA-Z0-9] *: it means any single number or alphabetic character. It can be understood as a repetition of any previous character. For example, u * can be understood as: the u arrangement of uuuu., is unlimited, and the * here can be replaced by {0,}), followed by "&".
This is a very simple example, but looking at the description of regular grammar on the Internet, I always feel that I can't understand it. I don't know if it's because I understand the problem of ability or whether it's written too esoteric.
In addition, explain why this can remove repetition, the principle is very simple, http://jb51.net?a=1&a=2 is replaced by the "& axix" format character will not be deleted last, you know, we put the new parameter at the end of each time in our loop.
This is the end of the article on "how to use regular expressions". 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.