In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces what the general rules of Flex regular expressions are, which can be used for reference by interested friends. I hope you can learn a lot after reading this article.
Let's first look at the concept and function of Flex regular expressions. Flex regular expressions (regularexpression) use a "string" to describe a feature, and then verify that another "string" conforms to this feature.
Introduction
Flex regular expression (regularexpression) is to use a "string" to describe a feature, and then to verify that another "string" matches this feature. For example, if the expression "ab+" describes a feature as "a" and any "b", then "ab','abb','abbbbbbbbbb'" fits this feature.
Flex regular expressions can be used to:
(1) verify that the string matches the specified characteristics, such as verifying that it is a valid email address.
(2) it is more flexible and convenient to find a string from a long text that meets the specified characteristics than to find a fixed string.
(3) used to replace, more powerful than ordinary replacement.
Flex regular expressions are actually very simple to learn, and a few more abstract concepts are easy to understand. The reason why many people feel that the Flex regular expression is more complex, on the one hand, because most of the documents do not explain from shallow to deep, and the concept does not pay attention to the order, which brings difficulties to the reader's understanding; on the other hand, the documents that come with various engines generally have to introduce its unique features, but this part of the unique features is not the first thing we need to understand. Let's take a look at other general rules in Flex regular expressions.
1. Other general rules
There are also some rules that are more common among the various Flex regular expression engines, which are not mentioned in the previous explanation.
1.1in expressions, you can use "\ xXX" and "\ uXXXX" to represent a character ("X" represents a hexadecimal number)
Formal character range
\ xXX
Characters with numbers in the range of 0x255, for example, spaces can be represented by "\ x20"
\ uXXXX
Any character can be represented by "\ u" plus a 4-digit hexadecimal number of its number, such as "\ u4E2D"
1.2 while the Flex regular expressions "\ s", "\ d", "\ w" and "\ b" denote special meaning, the corresponding capital letters denote the opposite meaning
Expressions can be matched
\ s
Match all non-white space characters ("\ s" matches individual white space characters)
\ d
Match all non-numeric characters
\ W
Match all letters, numbers, characters other than underscores
\ B
Match the non-word boundary, that is, the character gap when the left and right sides are in the "\ w" range or the left and right sides are not in the "\ w" range
1.3 has a special meaning in Flex regular expressions, you need to add "\" to match the character summary of the character itself.
Character description
^
Matches the starting position of the input string. To match the "^" character itself, use "\ ^"
$
Matches the end of the input string. To match the "$" character itself, use "\ $"
()
Marks the start and end positions of a subexpression. To match parentheses, use "\ (" and "\)"
[]
Use to customize expressions that match 'multiple characters'. To match the parentheses, use "\ [" and "\]"
{}
A symbol that modifies the number of matches. To match curly braces, use "\ {" and "\}"
.
Matches any character except the newline character (\ n). To match the decimal point itself, use "\."
?
The number of modification matches is 0 or 1. Want to match "?" For the character itself, please use "\?"
+
The number of modified matches is at least 1. To match the "+" character itself, use "\ +"
*
The number of modified matches is 0 or any times. To match the "*" character itself, use "\ *"
| |
The OR relationship between the left and right expressions. Match "|" itself, please use "\ |"
1.4 the subexpression in parentheses "()". If you want the matching result not to be recorded for later use, you can use the "(?: xxxxx)" format.
Example 1: when the expression "(?\ w)\ 1) +" matches "abbccddefg", the result is "bbccdd". Parentheses "(?" The matching results of the range are not recorded, so "(\ w)" is referenced using "\ 1".
1.5 introduction to common Flex regular expression attribute settings: Ignorecase,Singleline,Multiline,Global
Expression property description
Ignorecase
By default, letters in expressions are case-sensitive. Configure to Ignorecase to make matches case-insensitive. Some expression engines extend the concept of "case" to the case of the UNICODE range.
Singleline
By default, the decimal point. Matches characters other than the newline character (\ n). Configured to Singleline so that the decimal point matches all characters, including newline characters.
Multiline
By default, the expressions "^" and "$" match only the beginning and end ① positions of the string. Such as:
① xxxxxxxxx ②\ n
③ xxxxxxxxx ④
Configure as Multiline to make "^" match not only the ①, but also the position of the ③ before the start of the next line after the newline character, so that the "$" matches not only the ④, but also the position of the ② that ends the line before the newline character.
Global
It works primarily when the expression is used to replace, configured as Global to replace all matches.
Thank you for reading this article carefully. I hope the article "what are the general rules in Flex regular expressions" shared by the editor will be helpful to you. At the same time, I also hope you will support us 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: 275
*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.