Skip to main content

Posts

Showing posts from July, 2018

Introduction of Regular Expression

Regular expression is an special kind of API for finding sequence of character that specifies a pattern which can be searched for in a text and data. Usually regex or regular expression can be use to search,  edit and manipulate text and data. Java Regex API provides one interface and three classes in java.regex.util package. 1. MatchResult interface A MatchResult interface represents the result of match operation. It contains query methods used to determines the results of a match against a regex. 2. Matcher class    It is a regex engine that  interprets the pattern and perform match operations on a character sequence. 3. Pattern class A Pattern object is an compiled representation of a regex. 4. PatternSyntaxException class A PatternSyntaxException object is an unchecked exception that indicates a syntax error in a regex pattern. Predefined Character classes Construct Description . Any character (may or may not match line terminators) \d A digit:  [