Regular Expressions
Resources
- Deitel, end of chapter on strings
- Package
java.util.regex. Contains:
- class Pattern: for building regular expression
pattern strings. Documentation contains a good listing of Regular
Expression constructs
- class Matcher: methods for interpreting patterns
and determining matches
- interface MatchResult: methods for query results,
when matching a regular expression
- class PatternSyntaxException: thrown when there's a
syntax error in a regular expression
-
Tutorial on Regular Expressions -- from the Java web site
Validate.java -- A small
program to test a regular expression against a string
A few examples from the textbook
- Fig. 30.20 - 30.21 --
illustrates use of regular expressions to validate information in typical
address fields (like in a database)
- Fig. 30.23 -- example that
illustrates using regular expressions in String class methods
used for text replacements
- Fig. 30.24 -- Using class Matcher
with regular expression patterns