Class of the Month: JDK 1.4 Supports Regular Expressions

Regular expressions are a useful programming tool. The fact that Java now natively supports them simplifies many programming tasks that used to require cumbersome code.

provided by: 
Originally published at Internet.com


Regular expressions have been around for a long time. They come in very handy for text processing tasks. Some attribute the success of Perl to its superb ability of handling regular expressions. While there have been third-party classes that support regular expressions, with JDK 1.4, Java provides native support via the java.util.regex package.

Piroz Mohseni

Usage of regular expressions boils down to two components:

1. Defining the regular expression. This is a pattern that describes what is to be matched. 2. Applying the regular expression on a sequence of characters. Determining whether a match was found or not, successive finds, and replacements are some of the common operations involving regular expressions.

The Pattern class focuses on the first component. You use this class to define a regular expression. By representing the regular expression as an object, you can reuse the expression in your code. This is particularly useful in cases where you need to apply the same expression to multiple strings (e.g., line-by-line processing of a text file). The following line creates a pattern based on the regular expression "[0-9]" which matches any digits from 0 to 9. This pattern can also be represented as "/d"...

Read article at Internet.com site
Regional Articles
- Class of the Month: JDK 1.4 Supports Regular Expressions Alabama
- Class of the Month: JDK 1.4 Supports Regular Expressions Alaska
- Class of the Month: JDK 1.4 Supports Regular Expressions Arizona
- Class of the Month: JDK 1.4 Supports Regular Expressions Arkansas
- Class of the Month: JDK 1.4 Supports Regular Expressions California
- Class of the Month: JDK 1.4 Supports Regular Expressions Colorado
- Class of the Month: JDK 1.4 Supports Regular Expressions Connecticut
- Class of the Month: JDK 1.4 Supports Regular Expressions DC
- Class of the Month: JDK 1.4 Supports Regular Expressions Delaware
- Class of the Month: JDK 1.4 Supports Regular Expressions Florida
- Class of the Month: JDK 1.4 Supports Regular Expressions Georgia
- Class of the Month: JDK 1.4 Supports Regular Expressions Hawaii
- Class of the Month: JDK 1.4 Supports Regular Expressions Idaho
- Class of the Month: JDK 1.4 Supports Regular Expressions Illinois
- Class of the Month: JDK 1.4 Supports Regular Expressions Indiana
- Class of the Month: JDK 1.4 Supports Regular Expressions Iowa
- Class of the Month: JDK 1.4 Supports Regular Expressions Kansas
- Class of the Month: JDK 1.4 Supports Regular Expressions Kentucky
- Class of the Month: JDK 1.4 Supports Regular Expressions Louisiana
- Class of the Month: JDK 1.4 Supports Regular Expressions Maine
- Class of the Month: JDK 1.4 Supports Regular Expressions Maryland
- Class of the Month: JDK 1.4 Supports Regular Expressions Massachusetts
- Class of the Month: JDK 1.4 Supports Regular Expressions Michigan
- Class of the Month: JDK 1.4 Supports Regular Expressions Minnesota
- Class of the Month: JDK 1.4 Supports Regular Expressions Mississippi
- Class of the Month: JDK 1.4 Supports Regular Expressions Missouri
- Class of the Month: JDK 1.4 Supports Regular Expressions Montana
- Class of the Month: JDK 1.4 Supports Regular Expressions Nebraska
- Class of the Month: JDK 1.4 Supports Regular Expressions Nevada
- Class of the Month: JDK 1.4 Supports Regular Expressions New Hampshire
- Class of the Month: JDK 1.4 Supports Regular Expressions New Jersey
- Class of the Month: JDK 1.4 Supports Regular Expressions New Mexico
- Class of the Month: JDK 1.4 Supports Regular Expressions New York
- Class of the Month: JDK 1.4 Supports Regular Expressions North Carolina
- Class of the Month: JDK 1.4 Supports Regular Expressions North Dakota
- Class of the Month: JDK 1.4 Supports Regular Expressions Ohio
- Class of the Month: JDK 1.4 Supports Regular Expressions Oklahoma
- Class of the Month: JDK 1.4 Supports Regular Expressions Oregon
- Class of the Month: JDK 1.4 Supports Regular Expressions Pennsylvania
- Class of the Month: JDK 1.4 Supports Regular Expressions Rhode Island
- Class of the Month: JDK 1.4 Supports Regular Expressions South Carolina
- Class of the Month: JDK 1.4 Supports Regular Expressions South Dakota
- Class of the Month: JDK 1.4 Supports Regular Expressions Tennessee
- Class of the Month: JDK 1.4 Supports Regular Expressions Texas
- Class of the Month: JDK 1.4 Supports Regular Expressions Utah
- Class of the Month: JDK 1.4 Supports Regular Expressions Vermont
- Class of the Month: JDK 1.4 Supports Regular Expressions Virginia
- Class of the Month: JDK 1.4 Supports Regular Expressions Washington
- Class of the Month: JDK 1.4 Supports Regular Expressions West Virginia
- Class of the Month: JDK 1.4 Supports Regular Expressions Wisconsin
- Class of the Month: JDK 1.4 Supports Regular Expressions Wyoming
Related Articles
- Some Insight Into Inner Classes in Java, Part 1
Inner classes can simplify some design by enriching the classes in which they are defined. They might add a "facet" to the behavior of an enclosing class, thus enriching its interactions with other classes. They can also be used as access control points where the inner class can be used to provide controlled access to some resource or to define isolated callbacks or to other beneficial purposes.
- Class of the Month: Making HTTP Connections
- Use the BodyTagSupport Class to Add More Flexibility to JSP Pages
- Class of the Month: JSP Tag Libraries and the TagSupport Class
- Manage Your Application Settings via the Preferences API
- Class of the Month: The Reflection API
- Class of the Month: Control Event Executions with the New Timer Class
- User Code: W3Eval
- Class of the Month: GregorianCalendar
- User Code: A Little Socket App

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML