Get the App
SLTechnology News&Howtos  ›  Servers  › 

Extended regularity of regular expressions

Shulou Source: shulou.com Published: 2022-06-02 22:08:11 10月02日 Update

Extended regularity

Extended regularity means that the expression contains: +? | | {} and other symbols cannot be used directly in grep. You need to add\ extension |

If you don't want to add\ topology, you can use egrep or grep-E.

Extended regular: sed-r, and grep options, with +? | | r option is required when {} symbol is added, and\ topology is required if it is not added. |

Awk supports all functions of grep and sed by default.

The size of awk cannot be compared with numbers and letters, and this comparison cannot be made.

Extended regular? + | {}

? Extended regular representation:? There are 0 or 1 characters before it

A1? = > an or A1

The extended regular means that there are positive integers before the + characters.

| | extended regular representation: or |

{} indicates range

Some of the meanings of special symbols:

. Represents any one character

A b 0: the preceding character has 0 or more

Abc

Ab abccc

. It means greedy matching.

Egrep 'abc | 123' 1.txt

[] represents a character in square brackets

[a-zA-Z0-9] [abc] [a | @] [^]

^ indicates the beginning

$indicates the end

A {1,5} b {3}

() the characters in parentheses are regarded as a whole

(abc) {2} = "abcabc

(abc) +

Abc {2} = = > abcc

Awk-F'[#: |]'

Tags: Regular character symbol expression special greedy function meaning multiple size letter beginning parenthesis number whole integer square bracket time range support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology Huawei Microsoft Linux