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 > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what are the general rules of Flex regular expression, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
General rules for Flex regular expressions
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. In 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"
two。 In Flex regular expressions, while "\ s", "\ d", "\ w" and "\ b" denote special meaning, the corresponding capital letters indicate 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
3. It 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 "\ |"
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".
5. Introduction to commonly used Flex regular expression property 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.
These are all the contents of the article "what are the General rules for Flex 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: 209
*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.