Home  >  Article  >  类库下载  >  Regular expressions based on JAVA

Regular expressions based on JAVA

高洛峰
高洛峰Original
2016-10-19 09:30:491522browse

Add ^$ The entire string meets the requirements

You can pass without adding part of the string to meet the requirements

============================ =============================

: 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: empty)

D: Any non-numeric character

W: Any non-numeric character Word character

S: any non-blank character

. Any character

\. Represents ordinary.

========================== =================================

"+": appears more than 1 time in a row------ --"^d+$"

"*": Indicates that the content appears 0-several times----"^d*$"

"?": ​​Indicates that the content appears 0-1 times------- "^d?$"

============================================ ===============

[]

---------[ab]a and b can pass

---------[ a-z] means the range a, b, c...z can be used (the latter is larger than the front)

---------[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)

================================================ ===========

()--------The brackets are considered as a whole

|---------(123|321)---- ----123 or 321

============================================ ================

String emailRegEx = "^\d+$";

String email = "123";

System.out.println(email.matches(emailRegEx ));//true


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn