Team LiB
Previous Section Next Section

List of Listings and Outputs

Chapter 1: Regular Expressions

Listing 1-1: Finding Every Occurrence of the Letter A
Output 1-1: Result of Running FindA
Listing 1-2: MatchPhoneNumber.java
Output 1-2: Result of Running MatchPhoneNumber.java
Listing 1-3: MatchZipCodes.java
Output 1-3: Result of Running MatchZipCodes.java
Listing 1-4: MatchDates.java
Output 1-4: Result of Running MatchDates.java
Listing 1-5: MatchNameFormats.java
Output 1-5: Result of Running MatchNameFormats.java
Listing 1-6: MatchAddress.java
Output 1-6: Result of Running MatchAddress.java
Listing 1-7: MatchDuplicateWords.java
Output 1-7: Result of Running MatchDuplicateWords.java
Listing 1-8: ValidationTest.java
Output 1-8: Result of Running ValidationTest.java
Listing 1-9: ValidationTestWithPatternAndMatcher.java
Output 1-9: Result of Running ValidationTestWithPatternAndMatcher.java
Listing 1-10: StyleSearchAndReplace.java
Output 1-10: Result of Running StyleSearchAndReplace.java
Listing 1-11: StyleSplitExample.java
Output 1-11: Result of Running StyleSplitExample.java
Listing 1-12: Split.java
Output 1-12: Result of Running Split.java

Chapter 2: Introduction to the Java.util.regex Object Model

Listing 2-1: Using the compile Method
Listing 2-2: Pattern Matching Example
Listing 2-3: Matches Example
Listing 2-4: Pattern Splitting Example
Listing 2-5: PatternSplit.java
Output 2-1: Result of Running PatternSplit.java
Listing 2-6: Matcher Pattern Example
Listing 2-7: Matcher.reset Example
Output 2-2: Output for the Matcher.reset Example
Listing 2-8: Matcher.reset(CharSequence) Example
Output 2-3: Output for the Matcher.reset(CharSequence) Example
Listing 2-9: Matcher.start() Example
Output 2-4: Output for the Matcher.start() Example
Listing 2-10: Matcher.start(int) Example
Output 2-5: Output for the Matcher.start(int) Example
Listing 2-11: Matcher.end() Example
Output 2-6: Output for the Matcher.end() Example
Listing 2-12: Matcher.end(int) Example
Output 2-7: Output for the Matcher.end(int) Example
Listing 2-13: The Matcher.group() Method
Listing 2-14: Matcher.group(int) Method Example
Output 2-8: Output of the Matcher.Group(int) Example
Listing 2-15: MatcherGroupCountExample Example
Listing 2-16: Matcher.matches Example
Listing 2-17: Using the find() Method
Listing 2-18: Using the find(int) Method
Listing 2-19: Using the lookingAt Method
Listing 2-20: appendReplacement Method Example
Listing 2-20: Using appendReplacement with Subgroup Replacements
Listing 2-21: replaceAll Method Example
Listing 2-22: replaceFirst Method Example

Chapter 3: Advanced Regex

Listing 3-1: Working with Groups
Listing 3-2: Working with Subgroups
Listing 3-3: Working with Noncapturing Subgroups
Output 3-1: Output of NonCapturingGroupExample
Listing 3-4: Working with Back References
Listing 3-5: Greedy Qualifier Example
Listing 3-6: Possessive Qualifier Example
Listing 3-7: Reluctant Qualifier Example
Listing 3-8: Simple Positive Lookahead Example
Listing 3-9: Simple Negative Lookahead Example
Listing 3-10: Simple Positive Lookbehind Example

Chapter 4: Object-Oriented Regex

Listing 4-1: Using FileChannels to Access a File
Listing 4-2: The Regex Bean
Listing 4-3: The Persistence Code
Listing 4-4: The XML State of the Persisted Regex Object
Listing 4-5: Extract a Non-Java-Delimited Regex Pattern from a File
Listing 4-6: Overloaded getRegex Method
Listing 4-7: Sample Content of a Regex Cache File
Listing 4-8: Custom Property File Reader
Listing 4-9: Log Handler That Checks for Exceptions
Listing 4-10: Adding the Log Handler to Your Log
Listing 4-11: The Log Parser

Chapter 5: Practical Examples

Listing 5-1: Searching for a Phone Number
Listing 5-2: New Entries in the regex.properties File
Listing 5-3: Matching Zip Codes for Various Countries
Listing 5-4: Validating a Date
Listing 5-5: First Pass at the searchString Method
Listing 5-6: Modified searchString Method Belonging in the RegexUtil Class
Listing 5-7: Reading in File Content
Listing 5-8: Opening a File, Searching the File, and Returning the Results
Listing 5-9: Modifying the searchFile Method to Make It Friendlier
Listing 5-10: Accessing a File Through a MappedByteBuffer
Listing 5-11: Modifying the Content of a File Based on a Regex Pattern
Listing 5-12: Extracting Phone Numbers from a File
Listing 5-13: Search Current and Subdirectories for File Containing the Pattern

Team LiB
Previous Section Next Section