Add ^$ the entire string satisfies the requirement
Do not add part of the string to meet the requirements can pass
========================================================
\: Escape character
\d: Any number (digit: number)
\w: Any one word character (number, letter, underscore) (Word: Word)
\s: Any white space character (\ t \ r \ \f \x0b) (Space: Empty)
\d: Any non-numeric character
\w: Any non-word character
\s: Any non-whitespace character
. Any character
\\. The expression is normal.
=========================================================
"+": 1 consecutive occurrences--------"^\d+$"
"*": Indicates content appears 0-several times----"^\d*$"
"?": Indicates that the content appears 0-1 times-------"^\d?$"
=========================================================
[]
---------[Ab]a and B can pass
---------[A-z] indicates that the range a,b,c....z can be (later than the previous size)
---------[A-BD-E] multiple ranges
=========================================================
{}
{n} appears n times---------------"^[a]{n}$"----------(n A can pass)
{N,} at least n times---------------"^[a]{n,}$"---------(at least n a can pass)
{n,m} appears n-m times can be----"^[a]{n,m}$"-------(n-m A can pass)
=========================================================
()--------in parentheses as a whole
|---------(123|321)--------123 or 321
=========================================================
String Emailregex = "^\\d+$";
String Email = "123";
System. Out. println(email. Matches(Emailregex)); True
Regular expression of Java basics