Regular expressions brief entry

  • Regular Expressions

https://deerchao.net/tutorials/regex/regex.htm

\ b regular expression specified in a special code (Well, some people call it meta-character, metacharacter ), representing the beginning or end of a word, is the word boundary at

.  It is another element character matching except newline character arbitrary character

* Is also a meta-character, but it is not representative of the character, not the location, but the number - it specifies * content front can be continuously reused any number of times to get the whole expression match with

\ d is a new metacharacter, matches a single digit (0 or 1 , or 2 , or ......) .

0 \ d {2} - \ d {8}, where \ behind D {2} ({8}) of the front means \ d must match a sequence of repeated 2 times (8 times)

{5,12} is the number of repetitions of not less than 5 times, no more than 12 times

  • Metacharacters

Common metacharacters

Code

Explanation

.

It matches any character except newline

\w

Match letters or numbers or an underscore or Chinese characters (? Characters doubtful)

\s

Matches any whitespace

\d

Matching numbers

\b

Matches the beginning or end of a word

^

Matches the beginning of the string

$

The end of the match the string

  • Character escape \

\.with\*. Of course, to find \ itself, you have to use \\

  • Character classes, that is, [] range

\ [(0 \ d {2 }?) -]? \ D {8} This expression can match a telephone number in several formats , like (010) 88886666 , or 022-22334455 or 02912345678 like.

The first is an escape character \ (, it can appear 0 or 1 ()? , Followed by a 0, followed by two numbers (\ d {2}), then) or - or space in a, it appears once or absence (?), the last eight digits (\ d {8}).

  • Branch condition

With | the different rules separated

  • antonym

Commonly used antisense Code

Code / Syntax

Explanation

\W

Not match any letters, numbers, underscores, Chinese characters

\S

Matches any character is not whitespace

\D

Matches any non-numeric characters

\B

Position matching is not the beginning or end of a word

[^x]

In addition to matching x any character other than

[^aeiou]

In addition to matching aeiou any character other than these letters

 

Guess you like

Origin www.cnblogs.com/Jasper-changing/p/11023309.html