Among the regular linux / expansion expression (grep articles)

Regular expressions to use in linux shell script which we often used when regular expressions, so we'll sort out some of the expressions used, in order to enhance the ability of shell scripts

First, regular expressions (1)
through the practice of regular expressions grep command
such as line filters with us to the bbb field, you can go directly to get through grep "xx" file

[root@zhaocheng ~]# cat test1
aaa bbb ooo
cccc dddd eeee
fffff ggggg hhhhh bbbbb
kkkkk pppppp ssssss xxxxxx   mmmmmmmm
[root@zhaocheng ~]# grep "bbb" test1
aaa bbb ooo
fffff ggggg hhhhh bbbbb

For example, to filter out the lines beginning with aaa, we need to use to match the ^, ^ represents the beginning of a line fixed
quotation marks can be added without

[root@zhaocheng ~]# grep "^aaa" test1
aaa bbb ooo
[root@zhaocheng ~]# grep '^aaa' test1
aaa bbb ooo
[root@zhaocheng ~]# grep ^aaa test1
aaa bbb ooo

^ Match beginning of the line, and $ match end of the line, you can try, can not add quotes

[root@zhaocheng ~]# grep mm$ test1
kkkkk pppppp ssssss xxxxxx   mmmmmmmm
[root@zhaocheng ~]# grep 'mm$' test1
kkkkk pppppp ssssss xxxxxx   mmmmmmmm
[root@zhaocheng ~]# grep "mm$" test1
kkkkk pppppp ssssss xxxxxx   mmmmmmmm

For example, match a word, you can use directly ^ xx $ is matched with the beginning of the line end of the line, grep -n way output line number, - color color

[root@zhaocheng ~]# grep ^today$ test1
today

[root@zhaocheng ~]# grep -n --color ^today$ test1
1:today
[root@zhaocheng ~]# grep -n  ^today$ test1
1:today

So ^ $ is a blank line means, matching blank line, the fourth line outputs a space, using $ ^ can match the

[root@zhaocheng ~]# grep ^$ test1

[root@zhaocheng ~]# grep -n ^$ test1
4:

In grep to match the first word of a word or suffix

[root@zhaocheng ~]# grep "\<Beijing" test1
Beijing
[root@zhaocheng ~]# grep "beijinG\>" test1
beijinG
[root@zhaocheng ~]# grep "\<B" test1
Beijing
[root@zhaocheng ~]# grep "G\>" test1
beijinG

It can be fixed with the first word endings

[root@zhaocheng ~]# grep -n --color "\<beijin\>" test1
6:Beijing is beijin ya

In addition to \ <fixed first word can also use \ b can also be provided the first word
in addition to \> fixed suffix can also use \ b can be fixed suffix

[root@zhaocheng ~]# grep -n --color "\bccc" test1
5:cccc dddd eeee

[root@zhaocheng ~]# grep -n --color "eee\b" test1
5:cccc dddd eeee

[root@zhaocheng ~]# grep -n --color "\beeee\b" test1
5:cccc dddd eeee

This b and a brother B, this belongs to a match "non-word boundary"
can be seen when the match is the first bb bb matches except the first word to the capital
the following matching bbb match to the beginning of the first word in addition to others are to match

[root@zhaocheng ~]# grep -n --color "\Bbb" test1
2:aaa bbb ooo
7:fffff ggggg hhhhh bbbbb
[root@zhaocheng ~]# grep -n --color "\Bbbb" test1
7:fffff ggggg hhhhh bbbbb

Summary:
^: indicates a fixed line first, behind any content word character must appear at the beginning, in order to match
$: represents the fixed end of the line, in front of any word character must be content appears at the end in order to match
^ $: Indicates match blank lines , blank lines described herein represents 'Enter', the space or Tab, and so can not be regarded as blank lines described herein
^ abc $: exclusive line indicates when abc, will be matched to the
\ <or \ b: match word boundary, represents a fixed term first, behind the characters must be used as the header word appears
\> or \ b: matching a word boundary, represents a fixed ending its preceding character must appear as the word tail
\ B: matching non-word boundary, and \ Instead b

Second, the regular expression (2)
to find out which of a few lines of text that contains two consecutive letters image
such as find out which words begin with image file has yaml

[root@zhaocheng files]# grep -n "image" coredns.yaml 
111:        image: zhaocheng172/coredns:1.2.2
112:        imagePullPolicy: IfNotPresent

If you have a lot of words in a text, but only want to match the words in the same field contains two consecutive

[root@zhaocheng ~]# grep -n "b\{2\}" test3
4:bb
6:bbb

[root@zhaocheng ~]# grep -n "a\{2\}"  test3
1:aa
3:aaa a a aa
8:aaiip
9:aallo aahuy


Matches regular symbol number , which we often used to match any character when
represent any character of any length match
but in the regular expression, represent any number (including zero) before the character consecutive
such as matching A
the p-too is a can occur at any time, but must be followed along with p

[root@zhaocheng ~]# grep -n "a*p" test3
7:appaly aoopa
8:aaiip

* Match o that is, any character after the o **

[root@zhaocheng ~]# grep -n --color "o*" test2
1:aaa#bbb#ooo
2:cccc#dddd#eeee
3:fffff#ggggg#hhhhh
4:kkkkk#pppppp#ssssss

In wildcard represents any length character, and in a regular expression. To match

[root@zhaocheng ~]# grep -n --color "o.*" test1
1:today
2:aaa bbb ooo

Regular expression after a single represent any character, any two characters is .. are matched

[root@zhaocheng ~]# grep -n "y." test
6:sync:x:5:0:sync:/sbin:/bin/sync
[root@zhaocheng ~]# grep -n "y.." test
6:sync:x:5:0:sync:/sbin:/bin/sync
[root@zhaocheng ~]# grep -n "y..." test
6:sync:x:5:0:sync:/sbin:/bin/sync

Third, the regular expression (3) common symbols
[[: alpha:]] is matched with all the letters of any alphabet

[root@zhaocheng ~]# grep "[[:alpha:]]" test4
a
a9o
afghj9gh
abcd
aBDc
abdD
a124
a1a4
a%

I.e. with the addition of a letter with a default

[root@zhaocheng ~]# grep "a[[:alpha:]]" test4
afghj9gh
abcd
aBDc
abdD

It is matched with a rear three-letter

[root@zhaocheng ~]# grep "a[[:alpha:]]\{3\}" test4
afghj9gh
abcd
aBDc
abdD

Match with a rear two-letter

[root@zhaocheng ~]# grep "a[[:alpha:]]\{2\}" test4
afghj9gh
abcd
aBDc
abdD

For example, three characters must be lowercase, then
you can use [[: lower:]] represents any lowercase letters

[root@zhaocheng ~]# grep "a[[:lower:]]" test4
afghj9gh
abcd
abdD
[root@zhaocheng ~]# grep "a[[:lower:]]\{2\}" test4
afghj9gh
abcd
abdD


It can be used to represent any uppercase letters

[[:upper:]]

[root@zhaocheng ~]# grep "a[[:upper:]]\{1\}" test4
aBDc
[root@zhaocheng ~]# grep "a[[:upper:]]\{2\}" test4
aBDc

Common symbols
[[: alpha:]] represents any case letters
[[: lower:]] represents any lowercase letter
[[: upper:]] represents any capital letters
[[: digit:]] represents 0-9 any single number (including 0 and. 9)
[[: alnum:]] represents any number or letter
[[: space:]] represents any whitespace characters, including spaces, tab Kin
[[: punct:]] represents an arbitrary punctuation

In addition to [[: lower:]] may represent lowercase letters, another "[az]" may also refer to any one lowercase letter, [[: lower:]] and [az] is the same

[root@zhaocheng ~]# grep "[a-z]" test4
a
a9o
afghj9gh
abcd
aBDc
abdD
a124
a1a4
a%
[root@zhaocheng ~]# grep "[[:lower:]]" test4
a
a9o
afghj9gh
abcd
aBDc
abdD
a124
a1a4
a%

Similarly uppercase [AZ] and [[: upper:]] is the same

[root@zhaocheng ~]# grep "[A-Z]" test4
aBDc
abdD
[root@zhaocheng ~]# grep "[[:upper:]]" test4
aBDc
abdD


There are two methods to filter out after a two letter characters
[[: lower:]] Lowercase
[[: upper:]] Uppercase

[root@zhaocheng ~]# grep "a[a-z]\{2\}" test4
afghj9gh
abcd
apooo
aiuhh
abdD
[root@zhaocheng ~]# grep "a[[:lower:]]\{2\}" test4
afghj9gh
abcd
apooo
aiuhh
abdD
[root@zhaocheng ~]# grep "a[A-Z]\{2\}" test4
aBDc
[root@zhaocheng ~]# grep "a[[:upper:]]\{2\}" test4
aBDc

There is also a character is any of [[: alpha:]] it [a-zA-Z] same meaning

[root@zhaocheng ~]# grep "[[:alpha:]]" test4
a
a9o
afghj9gh
abcd
apooo
aiuhh
aBDc
abdD
a124
a1a4
a%
[root@zhaocheng ~]# grep "[a-zA-Z]" test4
a
a9o
afghj9gh
abcd
apooo
aiuhh
aBDc
abdD
a124
a1a4
a%


Similarly [0-9] and [[: digit:]] equivalents, denotes any single number between 0-9

[root@zhaocheng ~]# grep "[[:digit:]]" test4
a9o
afghj9gh
a124
a1a4
[root@zhaocheng ~]# grep "[0-9]" test4
a9o
afghj9gh
a124
a1a4


The middle [az] is all lowercase letters, can match the relevant character

[root@zhaocheng ~]# grep "b[ad]" test5
ba
bd

Can also match the special characters, [] represents any single character within a specified range to match

[root@zhaocheng ~]# grep "b[cP@*&]" test5
bc
bP
b&
b*
b@

In addition to these filter character symbol

[root@zhaocheng ~]# grep "b[^cP@*&]" test5
ba
bd
bf
bg

Use [^ az] excluded from this character

[root@zhaocheng ~]# grep "b[^A-Z]" test5
ba
bc
bd
bf
bg
b&
b*
b@
[root@zhaocheng ~]# grep "b[^a-z]" test5
bP
b&
b*
b@

Similarly
a single character [^ az] denotes a non-lowercase letters may be matched to
[^ AZ] non-capital letters represent a single character can be matched to
[^ a-zA-Z] represents a non-alphanumeric character can be matched to a single , numbers, or symbols such as
[^ a-zA-Z0-9] represents a non-alphanumeric, a single non-numeric characters to be matched, such as symbol

Prior to the interview [az] and [[: lower:]] ^ then the equivalent is equivalent to

[root@zhaocheng ~]# grep "b[^[:lower:]]" test5
bP
b&
b*
b@

I.e. [^ 0-9] and [^ [: digit:]] equivalent
[^ AZ] and [^ [: lower:] equivalent
[^ AZ] and [^ [: upper:]] equivalent
[^ a-zA-Z] and [^ [: alpha:] equivalent
[^ a-zA-Z0-9] and [^ [: alnum:] equivalent

In addition to [0-9], [[: digit:]] may represent a number, but also can be used \ d represent numbers

[root@zhaocheng ~]# grep -P "b\d" test5
b3
b4
b5


Display any single non-numeric character

[root@zhaocheng ~]# grep -P "b\D" test5
ba
bc
bd
bf
bg
bP
b&
b*
b@

\ d represents any single 0-9
\ D represents any single non-numeric character
\ t denotes a single match horizontal tab (tab corresponding to a healthy)
\ S indicates matches a white space characters, including spaces, tabs, etc. tab
\ S indicates a match single non-whitespace characters

Fourth, the regular expression escapes

Common symbol "\" escape character
before we used the Positive represents any character behind the match, but if you have this point in the text, the direct match, will be matched to the other, where we need to use the escape character \ to match

[root@zhaocheng ~]# grep "a.." test4
a9o
afghj9gh
abcd
apooo
aiuhh
aBDc
abdD
a124
a1a4
a..

[root@zhaocheng ~]# grep "a\.\." test4
a..

If you want to match a backslash itself, then
you can use the '' single quotation marks to match, '\' matches a

[root@zhaocheng ~]# grep 'a\\' test4
a\\\
[root@zhaocheng ~]# grep 'a\\\\' test4
a\\\
[root@zhaocheng ~]# grep 'a\\\\\\' test4
a\\\

Five, regular expressions Summary

################# ################# commonly used symbols
. Represents any single character.

  • Indicates that the preceding character consecutive any number of times, including zero.
    . Represents any character of any length, the wildcard same meaning.
    \ Represent escape sequences representing the symbol itself, when combined with the regular expression symbols.
    [] Represents any single character matches the specified range.
    [^] Represents any single character match outside the specified range.

Matches a single character associated ################# #################
[[: Alpha:]] represents any lowercase letters .
[[: lower:]] represents any lower-case letters.
[[: upper:]] represents any capital letters.
[[: digit:]] represents any single digit between 0 and 9 (including 0 and 9).
[[: alnum:]] represents any number or letter.
[[: space:]] represents any whitespace characters, including the "blank", "tab key" and so on.
[[: punct:]] represents any punctuation marks.
[^ [: alpha:]] represents a single non-alphabetic characters.
[^ [: lower:]] represents a single non-lowercase characters.
[^ [: upper:]] represents a single non-uppercase alphabetic characters.
[^ [: digit:]] represents a single non-numeric character.
[^ [: alnum:]] represents a single non-numeric non-alphabetic characters.
[^ [: space:]] represents a single non-whitespace characters.
[^ [: punct:]] represents a single non-punctuation character.
[0-9] and [[: digit:]] equivalent.
[az] and [[: lower:]] equivalent.
[AZ] and [[:]: upper] equivalent.
[a-zA-Z] and [[: alpha:]] equivalent.
[a-zA-Z0-9] and [[: alnum:]] equivalent.
[^ 0-9] and [^ [: digit:]] equivalent.
[^ az] and [^ [: lower:]] equivalent.
[^ AZ] and [^ [: upper:]] equivalent
[^ a-zA-Z] and [^ [: alpha:]] equivalent
[^ a-zA-Z0-9] and [^ [: alnum :]] equivalent
# short format not all regular expression parser can be identified.
\ d represents any single numbers 0 to 9.
\ D represents any single non-numeric characters.
\ t denotes a single match horizontal tab (the equivalent of a tab key).
\ s indicates matches a white space character, including "space", "tab Tab" and the like.
\ S indicates a match single non-whitespace characters.

################# ################# related to the number of matches
\? Means to match its preceding character 0 or 1
+ It represents a front matching character at least once, or repeatedly, the number of consecutive not capped.
{n} indicates that consecutive character n times, will be matched to.
{x, y} represent characters before the at least x consecutive times, up to y consecutive times, it can be matched to, in other words, as long as the number of previous consecutive characters between x and y, can be matched to.
{, n} represents the previous consecutive characters at most n times, at least 0, will accompany matched.
{n,} represents the previous consecutive characters at least n times, it will be matched to.

################# match the position of the boundary related #################
^: Indicates the anchor of the line, behind this character any of the content must appear at the beginning, in order to match.
$: Indicates the anchor end of the line, in front of any content of this character must appears at the end to match.
^ $: Indicates match blank lines, blank lines described here represents the "Enter", and "space" or "tab" and so can not be counted as blank lines described herein.
^ abc $: abc said in a separate line, it will be matched.
\ <Or \ b: matching a word boundary, it represents the first anchor words, characters must be behind it as the word's first appearance.
\> Or \ b: matching a word boundary, represents the anchor ending its preceding character must appear as the tail of the word.
\ B: matching non-word boundary, and \ b just the opposite.

################# ################# grouping and backward references
() denotes the packet, the contents of which we can be as a whole, the packet can be nested.
(ab) said it would ab as a whole to deal with.
\ 1 showing the expression refers to the entire first packet is matched to the positive result.
\ 2 represents the expression refers to the entire second packet to the regular matching result.

[root@zhaocheng ~]# cat shengri.txt 
小卡  19901119
小红  19920105
小里  19930211
小会  19940325
小黑  19950418
匹配1993开头的
[root@zhaocheng ~]# grep "\b1993[0-9]\{4\}\b" shengri.txt 
小里  19930211

Herein means \ <1992, \ b1992 words are fixed first, [[: digit:]] and [0-9] can represent numbers, {4} rear end 4 of the letters \>, \ b are fixed suffix

[root@zhaocheng ~]# grep "\<1992[[:digit:]]\{4\}\>" shengri.txt 
小红  19920105
[root@zhaocheng ~]# grep "\<1992[[:digit:]]\{4\}\b" shengri.txt 
小红  19920105
[root@zhaocheng ~]# grep "\b1992[[:digit:]]\{4\}\b" shengri.txt 
小红  19920105
[root@zhaocheng ~]# grep "\b1992[[:digit:]]\{4\}\>" shengri.txt 
小红  19920105

Sixth, extended regular expressions

Whether in basic regular expression or extended regular expressions, the meaning expressed some common symbols are the same
. Represents any single character.

  • Indicates that the preceding character consecutive any number of times, including zero.
    . Represents any character of any length, the wildcard same meaning.
    \ Represent escape sequences representing the symbol itself, when combined with the regular expression symbols.
    [] Represents any single character matches the specified range.
    [^] Represents any single character match outside the specified range.

[[: alpha:]] represents any case letters.
[[: lower:]] represents any lower-case letters.
[[: upper:]] represents any capital letters.
[[: digit:]] represents any single digit between 0 and 9 (including 0 and 9).
[[: alnum:]] represents any number or letter.
[[: space:]] represents any whitespace characters, including the "blank", "tab key" and so on.
[[: punct:]] represents any punctuation marks.
[^ [: alpha:]] represents a single non-alphabetic characters.
[^ [: lower:]] represents a single non-lowercase characters.
[^ [: upper:]] represents a single non-uppercase alphabetic characters.
[^ [: digit:]] represents a single non-numeric character.
[^ [: alnum:]] represents a single non-numeric non-alphabetic characters.
[^ [: space:]] represents a single non-whitespace characters.
[^ [: punct:]] represents a single non-punctuation character.
[0-9] and [[: digit:]] equivalent.
[az] and [[: lower:]] equivalent.
[AZ] and [[:]: upper] equivalent.
[a-zA-Z] and [[: alpha:]] equivalent.
[a-zA-Z0-9] and [[: alnum:]] equivalent.
[^ 0-9] and [^ [: digit:]] equivalent.
[^ az] and [^ [: lower:]] equivalent.
[^ AZ] and [^ [: upper:]] equivalent
[^ a-zA-Z] and [^ [: alpha:]] Equivalent
[^ A-zA-Z0-9] and [^ [: alnum:]] Equivalent

^: Indicates the anchor of the line, behind any content of this character must appear at the beginning, in order to match.
$: Indicates the anchor end of the line, in front of any content of this character must appears at the end to match.
^ $: Indicates match blank lines, blank lines described here represents the "Enter", and "space" or "tab" and so can not be counted as blank lines described herein.
^ abc $: abc said in a separate line, it will be matched.
\ <Or \ b: matching a word boundary, it represents the first anchor words, characters must be behind it as the word's first appearance.
\> Or \ b: matching a word boundary, represents the anchor ending its preceding character must appear as the tail of the word.
\ B: matching non-word boundary, and \ b just the opposite.

grep command by default only supports basic regular expressions, grep if you want to support extended regular expressions, you need to use the -E option, but 70% of these are common symbols, see the effect

[root@zhaocheng ~]# grep "b[a-z]" test5
ba
bc
bd
[root@zhaocheng ~]# egrep "b[a-z]" test5
ba
bc
bd
[root@zhaocheng ~]# grep -E "b[a-z]" test5
ba
bc
bd

Additional 30% compared with the substantially regular expressions, a number of slightly different, but it looks even better than regular appreciated that
the positive expression in {n} represents consecutive previous character n times, will be matched to
the extended regular expression, {n} indicates that character n consecutive times, will be matched to

In basic regular expressions, () denotes the packet, (ab) said it would ab as a whole to deal with
the extended regular expression, () denotes the packet, (ab) said it would ab as a whole to deal with

In the extended regular expression:
() denotes the packet
(ab) ab as a whole shows a process to
\ 1 showing positive expression refers to the entire first packet is matched to the result
\ 2 represents the expression of the entire reference two group matches to the regular results
? It represents a front matching character 0 or 1

  • Represents a front matching character at least once, or repeatedly, the number of consecutive not capped
    {n} indicates that consecutive character n times, will be matched to
    {x, y} denotes at least before consecutive characters x times , y consecutive times at most, can be matched to
    {, n} represents the previous consecutive characters at most n times, at least 0, will be matched to
    {n,} represents consecutive characters until at least n times, will be matched to

In the extended expression, there is a more commonly used symbols are the basic regular expression is not, it is the "|"

It means representation or

[root@zhaocheng ~]# cat test6
kubernetes.com
jenkins.com
rabbitmq.com
zookpeer.com
spring boot.com
dubbo.edu
spring cloud.net
helm.org

.Net at the end of the line to find out, xxx $ What was the ending

[root@zhaocheng ~]# grep "net$" test6
spring cloud.net
[root@zhaocheng ~]# egrep "net$" test6
spring cloud.net
[root@zhaocheng ~]# grep -E "net$" test6
spring cloud.net

For example, to find out the com, net, like the end of the line you can use the "|", you can use egrep or grep -E, () represents the contents of the brackets as a whole,


[root@zhaocheng ~]# egrep "(com|net)$" test6
kubernetes.com
jenkins.com
rabbitmq.com
zookpeer.com
spring boot.com
spring cloud.net
[root@zhaocheng ~]# grep -E "(com|net)$" test6
kubernetes.com
jenkins.com
rabbitmq.com
zookpeer.com
spring boot.com
spring cloud.net

You can also write, but not (com | net) $ precise, $ this is what the end

[root@zhaocheng ~]# grep -E "com|net" test6
kubernetes.com
jenkins.com
rabbitmq.com
zookpeer.com
spring boot.com
spring cloud.net

Common expressions extended summary of
commonly used symbols
. Represents any single character.

  • Indicates that the preceding character consecutive any number of times, including zero.
    . Represents any character of any length, the wildcard same meaning.
    \ Represent escape sequences representing the symbol itself, when combined with the regular expression symbols.
    | Means "or" meaning
    [] represents any single character within the specified range to match.
    [^] Represents any single character match outside the specified range.

It matches a single character associated
[[: alpha:]] represents any case letters.
[[: lower:]] represents any lower-case letters.
[[: upper:]] represents any capital letters.
[[: digit:]] represents any single digit between 0 and 9 (including 0 and 9).
[[: alnum:]] represents any number or letter.
[[: space:]] represents any whitespace characters, including the "blank", "tab key" and so on.
[[: punct:]] represents any punctuation marks.
[^ [: alpha:]] represents a single non-alphabetic characters.
[^ [: lower:]] represents a single non-lowercase characters.
[^ [: upper:]] represents a single non-uppercase alphabetic characters.
[^ [: digit:]] represents a single non-numeric character.
[^ [: alnum:]] represents a single non-numeric non-alphabetic characters.
[^ [: space:]] represents a single non-whitespace characters.
[^ [: punct:]] represents a single non-punctuation character.
[0-9] and [[: digit:]] equivalent.
[az] and [[: lower:]] equivalent.
[AZ] and [[:]: upper] equivalent.
[a-zA-Z] and [[: alpha:]] equivalent.
[a-zA-Z0-9] and [[: alnum:]] equivalent.
[^ 0-9] and [^ [: digit:]] equivalent.
[^ az] and [^ [: lower:]] equivalent.
[^ AZ] and [^ [: upper:]] Equivalent
[^ a-zA-Z] and [^ [: alpha:]] equivalent
[^ a-zA-Z0-9] and [^ [: alnum:]] Equivalent

The number of matching relevant
? Means to match its preceding character 0 or 1 times

  • It represents a front matching character at least once, or repeatedly, the number of consecutive not capped.
    {n} indicates that consecutive character n times, will be matched to.
    {x, y} represent characters before the at least x consecutive times, up to y consecutive times, it can be matched to, in other words, as long as the number of previous consecutive characters between x and y, can be matched to.
    {, n} represents the previous consecutive characters at most n times, at least 0, will accompany matched.
    {n,} represents the previous consecutive characters at least n times, it will be matched to.

Match the position of the boundary related
^: Indicates the anchor of the line, behind any content of this character must appear at the beginning, in order to match.
$: Indicates the anchor end of the line, in front of any content of this character must appears at the end to match.
^ $: Indicates match blank lines, blank lines described here represents the "Enter", and "space" or "tab" and so can not be counted as blank lines described herein.
^ abc $: abc said in a separate line, it will be matched.
\ <Or \ b: matching a word boundary, it represents the first anchor words, characters must be behind it as the word's first appearance.
\> Or \ b: matching a word boundary, represents the anchor ending its preceding character must appear as the tail of the word.
\ B: matching non-word boundary, and \ b just the opposite.

Grouping and backward reference
indicates a packet (), the contents of which we can as a whole, the group can be nested.
(ab) said it would ab as a whole to deal with.
\ 1 showing the expression refers to the entire first packet is matched to the positive result.
\ 2 represents the expression refers to the entire second packet to the regular matching result.

Guess you like

Origin blog.51cto.com/14143894/2473712