1. What is straightforward about regular expressions is a powerful tool for processing strings (used for string matching ).
2. for regular expressions, java. Lang. String, java. util. RegEx. pattern, and Java. util. RegEx. matcher are mainly used. The statement is mainly written in the following two ways:
A. stringstring = "sssss ";
String. Matches (". *"); // whether the string matches the regular expression in the form of ". *". If the string matches, true is returned, and vice versa.
B. Pattern pattern = pattern. Compile (". *"); // generates a model class that uses the regular expression ". *" as the model.
Matcher = pattern. matcher ("sssss"); // generates a matching class
Matcher. Matches (); // match
Note: Method A is easier to write than method B, while Method B provides more string matching methods than method.
3. Meanings of common characters in Regular Expressions:
•Represents any character * Represents zero or multiple duplicates
+ Indicates one or more repetitions. {} indicates the number of repetitions.
[] Indicates the value range () indicates the meaning of the Group
? Indicates zero or one repeat
Note: More regular expression symbols are described in Java. utit. RegEx. pattern.