Documentation

The Java™ Tutorials
Hide TOC
Regular Expressions正则表达式
Trail: Essential Java Classes

Lesson: Regular Expressions课程:正则表达式

This lesson explains how to use the java.util.regex API for pattern matching with regular expressions.本课程介绍如何使用java.util.regexAPI与正则表达式进行模式匹配。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.要阅读有关正则表达式的更多信息,请参阅本节以获取更多资源。

Previous page: Previous Lesson
Next page: Introduction