In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces what the regular expression rules of Flex are. It is very detailed and has certain reference value. Friends who are interested must finish reading it.
1.Flex regular expression rules
1.1 ordinary characters
Letters, numbers, Chinese characters, underscores, and punctuation marks that are not specifically defined in later chapters are all "ordinary characters". An ordinary character in an expression that matches the same character when it matches a string.
Example 1: the expression "c", when matching the string "abcde", the matching result is: successful; the matching content is: "c"; the matching position is: starts at 2 and ends at 3. (note: the subscript starts at 0 or 1, which may vary depending on the current programming language.)
Example 2: the expression "bcd", when matching the string "abcde", the matching result is: successful; the matching content is: "bcd"; the matching position is: starts at 1 and ends at 4.
1.2 simple escape characters
Some characters in Flex regular expressions that are inconvenient to write are preceded by "\". In fact, we are already familiar with these characters.
Expressions can be matched
\ r,\ n
Represents carriage return and newline characters
\ t
Tab character
\\
Stands for "\" itself.
◆ has other punctuation marks that have special uses in later chapters, and the prefix "\" represents the symbol itself. For example: ^, $have a special meaning, if you want to match the "^" and "$" characters in the string, the expression needs to be written as "\ ^" and "\ $".
Expressions can be matched
\ ^
Match the ^ symbol itself
\ $
Match the $symbol itself
\.
Matches the decimal point itself.
The matching method of these escape characters is similar to that of "normal characters". It also matches the same character.
Example 1: the expression "\ $d". When matching the string "abc$de", the matching result is: successful; the matching content is: "$d"; the matching position is: starts at 3 and ends at 5.
1.3 expressions that can match 'multiple characters'
Some representations in Flex regular expressions can match any one of the 'multiple characters'. For example, the expression "\ d" can match any number. Although you can match any of these characters, it can only be one, not multiple. It's like playing poker, big and small kings can replace any card, but only one card.
Expressions can be matched
\ d
Any number, any one of the 09s
\ w
Any letter or number or underscore, that is, any letter or number, that is, any letter or number or underscore, that is, any letter or number or underscore.
\ s
Any of the white space characters, including spaces, tabs, page feeds, etc.
.
The decimal point can match any character except the newline character (\ n).
Example 1: the expression "\ d\ d". When matching "abc123", the result of the match is: successful; the content of the match is: "12"; the position of the match is: starts at 3 and ends at 5.
Example 2: the expression "a.\ d". When matching "aaa100", the result of the match is: successful; the content of the match is "aa1"; the position of the match is: it starts at 1 and ends at 4.
1.4 Custom expressions that can match 'multiple characters'
Flex regular expressions use square brackets [] to contain a series of characters that can match any one of them. If you include a series of characters with [^], you can match any character other than one of them. By the same token, although you can match any one of them, it can only be one, not more than one.
Expressions can be matched
[ab5@]
Match "a" or "b" or "5" or "@"
[^ abc]
Match any character other than "a", "b", "c"
[fmurk]
Match any letter between "f" and "k"
[^ A-F0-3]
Match any character other than "A" ~ "F", "0" ~ "3"
Example 1: when the expression "[bcd] [bcd]" matches "abc123", the result of the match is: successful; the content of the match is "bc"; the position of the match is: it starts at 1 and ends at 3.
Example 2: when the expression "[^ abc]" matches "abc123", the result of the match is: successful; the content of the match is: "1"; the position of the match is: starts at 3 and ends at 4.
The above is all the content of the article "what are the Flex regular expression rules?" Thank you for reading! Hope to share the content to help you, more related 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.