Java-the use of two methods in a regular, object

Source: Internet
Author: User

Regular: "." and "\"
"." Any one character in the regular expression.
"\" is an ideographic character in a regular expression, and when we need to describe a special character that has been used by a regular expression, we can convert it to its original meaning by using "\".
"\" also has some pre-defined special content in regular expressions:
\d: Represents any number
\w: denotes any single word character (only numbers, letters, underscores)
\s: Represents any white space character (\ t \ r \ \f \x0b)
\d: Represents any non-numeric character
\w: Represents any non-word character
\s: Represents any non-whitespace character
"Character Set []" is used to describe a single character, inside the square brackets can define the content of the character, can also describe a range. For example: [ABC]: Indicates that the character can only be A or B or C
[123]: Indicates that the character can only be 1 or 2 or 3 when we need to describe all lowercase letters, we can use the range [A-z], indicating that the character can be any one lowercase letter.
You can also use [0-9] to indicate that the character can be any number.
You can also select within multiple scopes. For example, [a-za-z0-9_] means that the character can be any letter, a number, and an "underscore."
"+": indicates that content can appear at least 1 consecutive times
"*": Indicates content appears 0-several times
"?" : Indicates that the content appears 0-1 times
{n}: Indicates that content must appear n times
{n,m}: Indicates content appears n-m times
{N,}: Indicates content appears at least n times
() can be viewed as a whole, () can use the ' | ' to represent or relate.
The regular expression begins by adding "^" and adding "$" at the end to represent a whole, but using the default matching whole in Java.

1.1 String supports one of the related methods of regular expressions
Boolean matches (String Regec)
Matches the current string's format with the given regular expression to satisfy the requirement of the regular expression, and satisfies the Macthes method provided by the true,string the regular expression passed in, even if the non-bounding character is a full match
1.2 String supports regular expression method two:
String[] Solit (String regex)
Splits the contents of the current string by the part that satisfies the regular expression, and then returns the split string after it has been stored in an array.
If the split part is found to be contiguous in the split, an empty string is removed in the middle but if a continuous match is made at the end of the string, the split empty string is ignored
Third regular expression method supported by 1.3 string
String ReplaceAll (String regex,string str)
Replaces the part of the current string that satisfies the regular expression with the given string
2.1 Object Rewrite ToString Method principle
Typically, when we need to use the ToString method of an object, we should override the method because object provides a handle to the object when it returns: the class name @ address, which does not get actual information about the object's beauty
The string returned by ToString should contain the contents of the current object (property values) in the specific format of the actual design requirements of the current class
The Equals method of 2.2 object
The Equals method is designed to compare the contents of two objects in a consistent way
Comparison principle: The property values of two objects are compared, it is not necessarily required that there are attribute values, depending on the design requirements of the current class

I am a beginner, if the update is not good, welcome the Great God pointed out, thank you!

More exciting after the update, reprinted annotated!

Java-the use of two methods in a regular, object

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.