Tuesday, October 16, 2007

Pattern Matching and Regular Expression

Text processing frequently requires code to match text against patterns. That capability makes possible text searches, email header validation,custom text creation from generic text (e.g., "Dear Mr. Smith" instead of "Dear Customer"), and so on. Java supports pattern matching via its character and assorted string classes. Because that low-level support commonly leads to complex pattern-matching code, Java also offers regular expressions to help you write simpler code. What are regular expressions?A regular expression, also known as a regex or regexp, is a string whose pattern (template) describes a set of strings. The pattern determines what strings belong to the set, and consists of literal characters and metacharacters, characters that have special meaning instead of a literal meaning. The process of searching text to identify matches—strings that match a regex's pattern—is pattern matching.See following link for more detailshttp://www.javaworld.com/javaworld/jw-02-2003/jw-0207-java101.html