Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the use of regular expressions?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the use of regular expressions, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

Regular expression, also known as regular expression. (English: RegularExpression, often abbreviated as regex, regexp or RE in code), a concept in computer science. Regular expressions are often used to retrieve and replace text that conforms to a certain pattern (rule). Many programming languages support string manipulation using regular expressions. For example, a powerful regular expression engine is built into Perl. The concept of regular expressions was first popularized by tools in Unix, such as sed and grep. Regular expressions are usually abbreviated to "regex". The singular has regexp and regex, and the plural has regexps, regexes, and regexen.

Purpose of regular expression

Given a regular expression and another string, we can do the following:

1. Whether the given string conforms to the filtering logic of the regular expression (called "match"):

two。 We can get the specific part we want from the string through regular expressions.

Characteristics of regular expression

The characteristics of regular expressions are:

1. Very flexible, logical and functional

two。 You can quickly achieve complex control of strings in a very simple way.

3. For people who have just come into contact, it is more obscure.

Because the main application object of regular expression is text, it can be used in a variety of text editors, ranging from famous editors EditPlus to MicrosoftWord, VisualStudio and other large editors.

Regular engines can be divided into two main categories: one is DFA, the other is NFA. Both engines have a long history (more than 20 years now), and many variations have been produced by these two engines! So the introduction of POSIX avoids the continued emergence of unnecessary variants. In this way, the mainstream regular engines are divided into three categories: first, DFA, second, traditional NFA, third, POSIXNFA.

DFA engines execute in linear time because they do not require backtracking (and therefore they never test the same character twice). The DFA engine also ensures that the longest possible string is matched. However, because the DFA engine contains only a limited number of states, it cannot match a pattern with reverse references, and because it does not construct a display extension, it cannot capture subexpressions.

Thank you for reading this article carefully. I hope the article "what's the use of regular expressions" shared by the editor will be helpful to everyone? 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: 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report