***

From Java 1 Since 4, Java has been introduced into the Java core API util. Regex package, which is a valuable basic tool, can be used for many types of text processing, such as matching, searching, extracting and analyzing structured content

java. util. Regex is a class library package that uses a pattern customized by regular expressions to match strings. It includes two classes: pattern and matcher Pattern is a compiled representation pattern of regular expressions. In Java, it is easy to determine whether a string matches a pattern through a properly named pattern class Patterns can be as simple as matching a specific string, or they can be complex. Grouping and character classes, such as blanks, numbers, letters or controls, need to be used Because Java strings are based on uniform character encoding (Unicode), regular expressions are also suitable for international applications Method description of pattern class

Matcher a matcher object is a state machine that performs matching checks on strings based on the pattern object as the matching pattern. Firstly, a pattern instance customizes a compiled pattern of regular expression with syntax similar to Perl, and then a matcher instance performs string matching under the pattern control of the given pattern instance.

Method description of matcher class

Common wildcards in regular expressions:

There is no advantage in using regular expressions for single string comparisons The real strength of regex lies in the inclusion of character classes and quantifiers (*, +,?) On a more complex model

Character classes include:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>