This technique tells whether or not this string games the agreed regular look. A chant of this method of the appearance str.matches(regex) yields exactly the same result as the expression Pattern.matches(regex, str).
Here is the syntax of this method:
public boolean matches(String regex)
Here is the detail of parameters −
import java.io.*; public class Test { public static void main(String args[]) { String Str = new String("Welcome to Intellinuts.com"); System.out.print("Return Value :" ); System.out.println(Str.matches("(.*)Tutorials(.*)")); System.out.print("Return Value :" ); System.out.println(Str.matches("Tutorials")); System.out.print("Return Value :" ); System.out.println(Str.matches("Welcome(.*)")); } }
This will produce the following result:
Return Value :true Return Value :false Return Value :true
Here at Intellinuts, we have created a complete Java tutorial for Beginners to get started in Java.