The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。
See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
Lesson: Regular Expressions课程:正则表达式
This lesson explains how to use the java.util.regex
API for pattern matching with regular expressions.本课程介绍如何使用java.util.regex
API与正则表达式进行模式匹配。Although the syntax accepted by this package is similar to the Perl programming language, knowledge of Perl is not a prerequisite.尽管此包接受的语法与Perl编程语言类似,但了解Perl并不是先决条件。This lesson starts with the basics, and gradually builds to cover more advanced techniques.本课程从基础开始,逐步构建以涵盖更高级的技术。
-
Introduction介绍
Provides a general overview of regular expressions.提供正则表达式的一般概述。It also introduces the core classes that comprise this API.它还介绍了构成此API的核心类。
-
Test Harness测试线束
Defines a simple application for testing pattern matching with regular expressions.定义一个简单的应用程序,用于测试与正则表达式的模式匹配。
-
String Literals字符串文字
Introduces basic pattern matching, metacharacters, and quoting.介绍基本模式匹配、元字符和引用。
-
Character Classes字符类
Describes simple character classes, negation, ranges, unions, intersections, and subtraction.描述简单的字符类、求反、范围、并集、交点和减法。
-
Predefined Character Classes预定义字符类
Describes the basic predefined character classes for whitespace, word, and digit characters.描述空白、字和数字字符的基本预定义字符类。
-
Quantifiers量词
Explains greedy, reluctant, and possessive quantifiers for matching a specified expression x number of times.解释贪婪、不情愿和所有格量词,以匹配指定的表达式x次。
-
Capturing Groups捕获组
Explains how to treat multiple characters as a single unit.说明如何将多个字符视为单个单元。
-
Boundary Matchers边界匹配器
Describes line, word, and input boundaries.描述行、字和输入边界。
-
Methods of the Pattern ClassPattern
类的方法
Examines other useful methods of the Pattern
class, and explores advanced features such as compiling with flags and using embedded flag expressions.检查Pattern
类的其他有用方法,并探索高级功能,例如使用标志编译和使用嵌入式标志表达式。
-
Methods of the Matcher ClassMatcher
类的方法
Describes the commonly-used methods of the Matcher
class.描述Matcher
类的常用方法。
-
Methods of the PatternSyntaxException ClassPatternSyntaxException
类的方法
Describes how to examine a PatternSyntaxException
.描述如何检查PatternSyntaxException
。
-
Additional Resources额外资源
To read more about regular expressions, consult this section for additional resources.要阅读有关正则表达式的更多信息,请参阅本节以获取更多资源。