When writing programs that deal with strings, the need to find strings that conform to some complex rules is often used.
A regular expression is a tool for describing these rules, in other words, a regular expression is the code that records the rules of the text, but it is not a language
What exactly are regular expressions used for?
Regular text in text accidentally inherits Regular
have one?
How many?
Of course, the textual uses of regular expressions cannot be exhausted, because the existence of text is really common,
Status: Many computer users and developers have little or no idea about how to use regular expressions to manipulate text, and we set up this chapter to try to change that.
Chinese
Regular Expression or Regular Match
English
Regular Experssion,Regex、Regexp
significance:
Regular expressions will be the best choice for ordinary computer users or developers, especially those who often operate text or string search and replacement.
Have your own set of grammar rules in regular expressions
Common syntax includes
character match
duplicate match
character positioning
escape match
Other advanced grammars (character grouping, character substitution, and character decision-making)
match as is
When matching as it is, the same direct characters are used, what you see is what you get!
Metacharacter matching
A class of characters can be matched using metacharacters, which can be a single character or a pair of characters (the previous character is usually a backslash)
\d matches digits (0-9)
\D matches non-digits
\w matches any single character
\W matches a non-single character
\s matches whitespace characters
\S matches non-empty characters
. matches any character
[...] matches any character in parentheses
^ matches the beginning of the string
$ matches the end of the string
\b matches a word boundary
\B matches the non-boundary part of a word