Regular expressions
1, the regular expression is straightforward to deal with the string of sharp objects (for string matching).
2, about regular expressions in Java mainly used in the Java.lang.string,java.util.regex.pattern and java.util.regex.Matcher these three classes. Its writing mainly has the following two kinds:
A, string string = "Sssss";
String.matches (". *");/whether this string matches a regular expression in the form of ". *" If the match returns TRUE or vice versa.
b, pattern patterns = Pattern.compile (". *");//Generate a model class with a ". *" Regular expression model
Matcher Matcher = Pattern.matcher ("sssss");//generate a matching class
Matcher.matches ();//To match
Note: A method is more convenient than B, while B compares a provides more string matching methods.
3, regular expressions commonly-spoken characters meaning:
˙ represents any one character * indicating 0 or more repetitions
+ Represents the repetition of one or more times {}
[] represents a range of values () that represents the meaning of a group
。 Repeat 0 times or once
Note: The symbols for more regular expressions are explained in Java.utit.regex.Pattern.