In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces what the regular expression patterns are, which can be used for reference. Interested friends can refer to them. I hope you will gain a lot after reading this article.
There are three modes of regular expression: greedy mode, lazy mode and exclusive mode.
Finally, you summed up a table, as follows:
From this table, we can determine whether the regular expression you write is efficient or not. In this way, greed mode, lazy mode, monopoly mode are very easy to judge.
In addition, we can see the pattern through the comparison of official documents:
Greedy mode is to add a qualifying symbol after the X character such as:? , *, +, {n}, {n,}, {nrecom}
The lazy pattern is marked with a qualifying symbol:? After, *, +, {n}, {n,}, {n ·m}, add "?", such as: Xbox?
Exclusive mode, also known as embezzlement mode, is marked with a qualifying symbol:? , after, *, +, {n}, {n,}, {n ·m}, add "+", such as: Xbox +
Let's look at an example of a greedy pattern:
For Reluctant lazy mode, the demo is as follows:
Possessive exclusive mode.
Although the code of the three patterns is very simple, some "slackers" in the group have put forward new requirements. Can you write a tool to analyze. So I don't have to learn by rote.
That's a good idea. And, according to the table above, you can manually write a regular backtracking analysis tool yourself. The principle is very simple, you can judge whether the regular expression is exclusive, lazy, and greedy. If there is one of these features, it is the pattern of the feature.
According to this idea, I believe you can write such a program. Of course, it doesn't matter if not. I recommend a tool for you, regexbuddy. This tool looks like this:
The tool supports regular expressions in many programming languages, such as perl,pcre,javascript,python,ruby,c#,java, etc., and can generate program code automatically, and there are a large number of common regular expressions inside.
It's easy to use, it's cool, it's cool all the time!
Thank you for reading this article carefully. I hope the article "what are the patterns of regular expressions" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related 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: 285
*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.