Google


ADBRITE ads links
You are here: CodeIdol.com > Java > The Java Tutorial Fourth Edition: A Short Course on the Basics > Regular Expressions

SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

The Java Tutorial Fourth Edition: A Short Course on the Basics



Chapter 13. Regular Expressions THIS chapter explains how to use the java.util.regex API[1] for pattern matching with regular expressions. Although the syntax accepted by this package is similar to the Perl programming language,[2] knowledge...



Introduction What Are Regular Expressions? Regular expressions are a way to describe a set of strings based on common characteristics shared by each string in the set. They can be used to search, edit, or manipulate text and data. You must lear...

read more: Introduction


Test Harness This section defines a reusable test harness, RegexTestHarness.java,[6] for exploring the regular expression constructs supported by this API. The command to run this code is java RegexTestHarness; no command-line arguments are accept...

read more: Test Harness


String Literals The most basic form of pattern matching supported by this API is the match of a string literal. For example, if the regular expression is foo and the input string is foo, the match will succeed because the strings are identical. Tr...

read more: String Literals


Character Classes If you browse through the Pattern class specification, you'll see tables summarizing the supported regular expression constructs. Table 13.1 describes character classes. Table 13.1. Character Classes[abc]a, b, or c (simple class...



Predefined Character Classes The Pattern API contains a number of useful predefined character classes, which offer convenient shorthands for commonly used regular expressions. In Table 13.2, each construct in the left-hand column is shorthand f...



Quantifiers Quantifiers allow you to specify the number of occurrences to match against. For convenience, the three sections of the Pattern API specification describing greedy, reluctant, and possessive quantifiers are presented in Table 13.3. At ...

read more: Quantifiers


Capturing Groups Earlier we saw how quantifiers attach to one character, character class, or capturing group at a time. But until now, we have not discussed the notion of capturing groups in any detail. Capturing groups are a way to treat multipl...

read more: Capturing Groups


Boundary Matchers Until now, we've only been interested in whether or not a match is found at some location within a particular input string. We never cared about where in the string the match was taking place. You can make your pattern matches...



Methods of the Pattern Class Until now, we've only used the test harness to create Pattern objects in their most basic form. This section explores advanced techniques such as creating patterns with flags and using embedded flag expressions. It als...



Methods of the Matcher Class This section describes some additional useful methods of the Matcher class. For convenience, the methods listed below are grouped according to functionality. Index Methods Index methods provide useful index values ...



Methods of the PatternSyntaxException Class A PatternSyntaxException is an unchecked exception that indicates a syntax error in a regular expression pattern. The PatternSyntaxException class provides the following methods to help you determine wha...



Summary In this chapter, you learned that regular expressions are a way to describe a set of strings based on common characteristics shared by each string in the set. The Java programming language supports regular expressions via the java.util.reg...

read more: Summary


Additional Resources For a more precise description of the behavior of regular expression constructs, we recommend reading the book Mastering Regular Expressions by Jeffrey E. F. Friedl (O'Reilly, 2003). ...



Questions and Exercises: Regular Expressions Questions 1.What are the three public classes in the java.util.regex package? Describe the purpose of each.2.Consider the string literal "foo". What is the start index? What is the end index? Explain...


SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

You are here: CodeIdol.com > Java > The Java Tutorial Fourth Edition: A Short Course on the Basics > Regular Expressions
   
Related tags







Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......






© CodeIdol Labs, 2007