Regular Expression is an API that is used to defining String patterns that we want to match to strings.
Java provides java.util.Regex package for pattern matching .
We can perform such tasks –
• String matching with validation criteria.
• Data Extraction
Package consists of 3 classes Pattern, Matcher and PatternSyntaxException.
1. Pattern – It defines the patterns that you want to search.
2. Matcher – It is used for performing matching operations of pattern(the string you have entered).
3. PatternSyntaxException – It indicates exceptions in Regular Expression Pattern. And package also consist of 1 Interface..MatchResultInterface –
Hold the results of a successful match of a Pattern against a given String.
A simple program of regex.
These are used to match the characters in the specefied string.
Meta characters have predefined meanings. They works as short code.
Quantifiers define how many times an element can occur.
In this Program we have used matching symbols, meta characters and quantifiers.