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 > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
I would like to share with you what the basic concept of regular expression is. I believe most people don't know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it!
What is a regular expression
Regular expression (Regular Expression) originated from the early study of human nervous system. Neurophysiologists Warren McCulloch and Walter Pitts have developed a method to describe neural networks mathematically. In 1956, mathematician Stephen Kleene published a paper entitled "representation of neural network events", in which the concept of "regular expression" was introduced. In this paper, regular expressions are called "algebraic expressions of regular sets". Therefore, the term "regular expression" is adopted. There are many ways to define regular expressions, as follows:
A regular expression is a formula that uses a certain pattern to match a class of strings, which is mainly used to describe the tool of string matching.
A regular expression describes a pattern of string matching. It can be used to check whether a string contains a certain substring, replace a matching substring, or extract a substring that meets a certain condition from a string.
A regular expression is a text pattern that consists of ordinary characters (such as characters a to z) and special characters (called metacharacters). The regular expression acts as a template that matches a character pattern with the searched string.
Regular expressions are tools used to describe certain rules. These rules are often used to deal with finding or replacing strings in strings. In other words, a regular expression is the code that records text rules.
A regular expression is to use a "string" to describe a feature, and then to verify that another "string" matches this feature.
Readers who have studied the principles of compilation may know uncertain finite automata (Non-deterministic finite automaton, referred to as NFA) and deterministic finite automata (Deterministic finite automaton, referred to as DFA). In fact, regular expression is an uncertain finite automaton. The biggest difference between NFA and DFA lies in their state transition functions. NFA can interpret the same string in many ways, while DFA has only one way to understand it. Because of this, NFA may backtrack during the matching process, and NFA is generally less efficient than DFA. Therefore, it is necessary to minimize backtracking when writing regular expressions to improve the efficiency of regular expressions.
If you have used the wildcards * and? for file lookup under Windows or DOS, it is not difficult to understand regular expressions. If you need to find all Word documents, you may use the expression * .doc. Where the character * is a wildcard character that can represent any string. Regular expressions are similar to wildcards, and it can also use some characters (such as characters.) to represent any character. However, it is more accurate than wildcards.
In regular expressions, matching is the most commonly used word, which describes the action results of regular expressions. Given a piece of text or string, use a regular expression to find a string that matches the regular expression from the text or string. It is possible that there is more than one part of a text or character that satisfies a given regular expression, and each such part is called a match. Among them, there are three types of matching:
Adjective matching, that is, a string matches a regular expression.
Verbal matching, that is, matching regular expressions in text or string.
A nominal match, that is, the part of a string that satisfies a given regular expression.
Regular expressions are widely used, especially in string processing. At present, regular expressions have been widely used in many software, such as Linux, Unix, HP and other operating systems, C#, PHP, Java and other program development environments, as well as a lot of application software, we can see the application of regular expressions of one kind or another. Common applications of regular expressions are as follows:
Verify a string, that is, to verify that a given string or substring meets the specified characteristics, such as verifying that it is a legitimate e-mail address, verifying that it is a legitimate HTTP address, and so on.
Finding strings and finding strings that match the specified characteristics from a given text is more flexible and convenient than finding fixed strings.
A replacement string, that is, replacing substrings in a given string that match the specified characteristics with other strings, is more powerful than a normal substitution.
Extract a string, that is, extract a substring that meets the specified characteristics from a given string.
These are all the contents of the article "what are the basic concepts of regular expressions?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.