Java String matches Example
String class matches method example
String class matches method example. This example shows you how to use matches method.This method Tells whether or not this string matches the given regular expression.
Syntax:-matches(String regex)
Here is the code:-
/*
* @(#) Matchesstring.java
*Program Shows Tells whether or not this string matches the given regular expression.
* @Version 01-May-2008
* @author Rose India Team
*/
//import java.util.regex.Pattern;
import java.util.regex.*;
public class Matchesstring
{
public static void main(String args[])
{
String regex = "ad*";
String input = "add";
boolean isMatch = Pattern.matches(regex,input);
System.out.println(isMatch);//return true
}
} |
| Java2html |
null
|