In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Regular expressions:
A regular expression (regular expression, RE) is a character pattern used to match a specified character during a lookup. In most programs, regular expressions are placed between two regular slashes; for example, / lo] ve/ is a regular expression defined by a forward slash, which has a powerful text matching function and can process text quickly and efficiently in the text ocean.
It will match the same pattern that appears anywhere in the row being looked up. In regular expressions, metacharacters are the most important concept.
Metacharacters:
Definition: metacharacters are characters that express a meaning different from the literal one.
Shell metacharacters (also known as wildcards) are parsed by shell, such as rm-rf * .pdf, and metacharacter * Shell parses them into any number of characters.
Regular expression metacharacters are parsed by various programs that perform pattern matching operations, such as vi, grep, sed, awk, python
1. Classification of regular expressions:
The string expression method of regular expression can be divided into basic regular expression and extended regular expression according to different degree of rigor and function. The underlying regular expression is the most basic part of a commonly used regular expression.
In the common file processing tools in Linux systems, grep and sed support basic regular expressions, while egrep and awk support extended regular expressions.
= = basic regular expression metacharacter (gerp)
Example of metacharacter function ^ line beginning locator: ^ love$ line end locator: love$. Match a single character: l.. e * match leader 0 to multiple times: ab*love.* any number of characters [] match a character within the specified range: [lL] ove [-] match a character within the specified range: [a-z0-9] ove [^] matches characters that are not in the specified group: [^ a-z0-9] ove\ is used to escape metacharacters: love\. \
< 词首定位符 :\ 词尾定位符 :love\>X\ {m\} character x repeats m times: O\ {5\} x\ {m,\} character x repeats m times or more: o\ {5,\} x\ {mmagin n\} character x repeats m to n times: o\ {5jue 10\}
"*" matches only the leading character.
One character within the matching range of "[]"
The role of "^" is different inside and outside the metacharacter set "[]" symbol.
The use of escape character "\" and the use of special metacharacters
{} limit the number of matches
Extended regular expression metacharacter (egrep)
+ match one or more leading characters [a Murz] + ove? Match zero or one leading character lo?ve a | b match an or b love | hate () group character loveable | rs love (able | rs) ov+ (..) (.)\ 1\ 2 tag matching character (love) able\ 1erx {m} character x repeat m times o {5} x {m,} character x repeat at least m times o {5,} x {m} n} character x repeat m to n times
() matches all the characters in () in the same order
2. Text processor: grep and sed support basic regular expressions in common file processing tools in Linux systems, while egrep and awk support extended regular expressions.
Grep/egrep: filter, find.
Grep [option] 'Operation' parameter
Common option
-n: display line number-I: regardless of case-v: reverse search-c: statistics
See the following chapter for awk and sed.
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.