provided by: 
Originally published at Internet.comRegular 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