Regex(Regular Expressions) in Java
Regular Expressions or Regex in Java is basically considered as an API for definition of different string patterns in order to perform various string manipulations operations over here.
Regex in Java considers different classes like Pattern Class,Matcher Class.
Lets go through each of the above defined classes:
Pattern Class:Pattern Class is basically used to create a pattern , which can be considered as a reference for string matching, let us go through the below code snippet.
As shown in the above code snippet we have created a pattern by making use of Pattern Class over here.
Get Surajkh’s stories in your inbox
Join Medium for free to get updates from this writer.
Matcher Class: is being used to match a String for the relevant Pattern being defined by the Pattern Class.
Let us go through the below code snippet :
Now we can consider the boolean result that is being fetched after performing the matching of the string to the defined string pattern using the matches() method.
Thank You.










