JAVA-based regular expressions and java Regular Expressions
Add ^ $ the entire string meets the requirements
You can use
========================================================== ======================
\: Escape Character
\ D: Any number (digit: Number)
\ W: Any word character (number, letter, underline) (word: word)
\ S: any blank character (\ t \ r \ n \ f \ x0B) (space: NULL)
\ D: any non-Numeric Character
\ W: any non-word character
\ S: any non-blank character
. Any character
\. Indicates normal.
========================================================== ========================
"+": Appears more than once in a row -------- "^ \ d + $"
"*": Indicates that the content appears 0-several times ---- "^ \ d * $"
"? ": Indicates that the content appears 0-1 -------" ^ \ d? $"
========================================================== ========================
[]
--------- [AB] a and B can pass
--------- [A-z] indicates that the range a, B, c... z can all be (the latter is bigger than the former)
--------- [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} can appear n-m times ---- "^ [a] {n, m} $" ------- (n-m a can pass)
========================================================== ========================
() -------- Think of it as a whole in parentheses
| --------- (123 | 321) -------- 123 or 321
========================================================== ========================
String emailRegEx = "^ \ d + $ ";
String email = "123 ";
System. out. println (email. matches (emailRegEx); // true