Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Regular expression format

Shulou Source: shulou.com Published: 2022-06-01 03:52:15 10月03日 Update

Regular expression metacharacters:

. Match any single character

*: match the preceding characters any number of times

? Match the preceding characters once or 0 times

\ {mdirection n\}: match the preceding characters at least m times and n times at most

Position Anchor:

^: anchor the beginning of the line, and the content after this character must appear at the beginning of the line

$: anchor the end of the line, and the content after this character must appear at the end of the line

^ $: blank line

\

< :其后面的内容必须作为单词首部出现 \>

The content after it must appear as the end of the word

[]: any character in the specified range. Egrep [q,w] / tmp/test

Regular expression of extension:

. Match any single character

*: match the preceding characters any number of times

? Match the preceding characters once or 0 times

+: match the preceding characters at least once

{m,n}:

C | Cat! = c | (Cat)

Example: ifconfig | egrep-o "(\\.) {3}\" you can get all the IP

Integer judgment

-eq equals

-ne is not equal to

-gt is greater than

-ge greater than or equal to

-lt less than

-le is less than or equal to

Document judgment

-e: whether the file exists

-f: test whether the file is a normal file

-d: test whether it is a directory

-r

-w read and write execution is for the current user

-x

String test

=, =: [string1 = string2] or [string1 = = string2]

! =: test whether two strings are not equal to

-n string: tests whether the specified string is empty

-z string: tests whether the specified string is not empty

Tags: Character test content string file regular expression on line single word face normal two position example metacharacter trailer integer user directory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Tech Info Huawei Shulou Technology Xiaomi