3. Regular expressions
A string consisting of some special meaningful characters (rote)
Atomic: The most basic constituent unit of a regular expression
The character of the regular expression special meaning:. + They cannot be represented individually, and if they are to be represented, they need to be
\ While in Java \ the string needs \ \ Represent
So to represent the above four characters will be used \ \. \\* \\? \\+
Special significance
3.3 Meta characters
Used to modify atoms, not to appear alone.
. Any character other than line breaks
* Indicates that the atom can occur 0 times 1 or more times {0}
? {0,1}
+ {1,}
{} Number of times a custom atom appears
{m} appears m times
{M,n}m to n times, including m,n
{m,} appears at least m times
^ What must I start with?
What must be the end of the $
| Representation or relationship
\\d represents an arbitrary decimal number [0-9]
\\d represents any character other than a number.
\\s represents an arbitrary blank word spaces [\n\r\t\f]
\\s represents a non-blank
\\w denotes any one character (alphanumeric underscore) a-za-z0-9_[a-za-z0-9_]
\\w means non-a-za-z0-9_
D. Define an atom yourself
[Any one between the 0-9]0-9
[5-8]
[A-z5-8]
[^0-9] ^ representative take the reverse
[]
Patten
String: Matches split
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Regular expression "use syntax"