1. What is a regular expression
An ordered string that defines a set of lookup patterns
2. What are the basic syntax of regular expressions
Single match single character
. Any character
\d Number [0-9]
\d non-digital [^0-9]
\s white space character [\t\n\x0b\f\r]
\w a character [a-za-z_0-9]
Range matches a single character
[ABC] Simple class
[^ABC] Negation
[A-za-z] Range
[A-d[m-p]] [A-dm-p] Union
[A-z&&[def]] [Def] Intersection
[A-Z&&[^BC]] [Ad-z] Subtraction
[A-z&&[^m-p]] [A-lq-z] Subtration
---| match multiple characters greedy mode
? 0 or 1 x
* Any number of the same characters (0 or more) "". Matches ("m*")
+ 1 or more characters
X{n} =n
X{n,} >=n
X{N,M} <=n <=m
--| Boundary Matching
^ABC start with "abc" [^ABC] not "a", "B", "C"
abc$ End With "ABC"
3. How to use regular expressions in Java
Pattern class Matcher Class
The pattern P = pattern.compile () method//First generates a Pattern object for the regular expression
Matcher m = P.matcher () method//Create a Mathcher object from the found content by using the Pattern object Matcher method
M.matches () method
M.find () method//order matching
M.group () method//through find, you can get the group
M.reset () method
M.start () method
M.end () method
4. High-order usage of regular expression
Grouping parentheses number opening parenthesis
Greedy mode. *
Non-greedy mode. *?
java-Regular Expressions