Linux Bash the regular expression

First Note: Regular expressions and wildcards are completely different concepts. Wildcard  (wildcard)  represents  Bash  a function of operation of the interface, and is a regular expression string manipulation way, must be distinguished.

Regular expressions  (Regular Expression)  is arranged through a number of special characters, to find / replace / delete one or more lines of text strings. That is an expression, regular expressions are used in the string processing, it is not a utility, but a standard basis for string manipulation, if we want to deal with the way regular expression string, support tools program is necessary to use regular expressions, such as  vim, sed , awk , grep  and so on.

A regular expression is a pattern that describes a set of strings.
regexp are constructed analogously to arithmetic expressions, by using various operators to combine smaller expressions.
grep understands three different regexp syntax: “basic” (BRE), “extended” (ERE) and “perl” (PCRE).
In GNU grep, there is no difference in available functionality between basic and extended syntaxes.

 The first part introduces the basic regular expression is a fundamental part of Table 1-1, if you want can be used on most portable machine script, only an essential part of a good choice.

 Then look at the second part, for the POSIX Shell characters, as shown in Table 1-2, substantially according to the symbol can guess the meaning, i.e., a so-called too literally, easier to remember. This is part of the basic regular, extended regular format and Perl regular expressions are the same, specific symbols specific meaning.

Such certain named classes of characters are predefined within bracket expressions. Their names are self explanatory.

 

 Next is the third part, and the use of meta characters and their meanings example, as shown in Tables 1-3, are given here only basic regular and extended regular character element supported for Perl style regular support more part of the show's characters later. 

The symbol \b matches the empty string at the edge of a word, and \B matches the empty string provided it's not at the edge of a word.
The symbol \w is a synonym for [_[:alnum:]] and \W is a synonym for [^_[:alnum:]].
The symbols \< and \> respectively match the empty string at the beginning and end of a word.

The fourth part, is expanding for the regular and Perl-style regular, it supports more features and more complicated, but also more convenient to use, that there are some new representation and agreement on the basic regular on Table 1-4 Fig.

 The last part, Perl-style regular with respect to the basic regular and extended regular terms to support a richer meta-characters, as shown in Table 1-5, have more definition and usage.

Reference material

[1]  Shell Regular Expressions

[2] ASCII

Guess you like

Origin www.cnblogs.com/phillee/p/10949796.html