This Example describes the way to match the String using regular expression. For this we are going to make program named Matching_Casesensitive.java. The steps involved in program Matching_Casesensitive.java are described below:-
String regex="^java":-Defining regression as string. Here (^java) means all the words which are named as java .
Pattern.CASE_INSENSITIVE| Pattern.MULTILINE:-This enables the pattern to match case insensitive. The word can either be in caps or not.
Output of the program:-
|Words from the Text is:-
java has classes
Java has methods
JAVA have regular expressions
Regular expressions are in Java
Finded words from the Text is:-
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: August 30, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles