List of usage examples for java.lang String matches
public boolean matches(String regex)
From source file:Main.java
public static void main(String[] argv) throws Exception { String string = "I am Java"; boolean b = string.matches("(?i).*i am.*"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String string = "I am Java"; boolean b = string.matches("(?i).*adam"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String string = "I am Java"; boolean b = string.matches("(?i)i am.*"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String string = "I am Java"; boolean b = string.matches("(?i).*Java"); }
From source file:MainClass.java
public static void main(String args[]) { String candidate = "Java 6"; String pattern = "Java \\d"; System.out.println(candidate.matches(pattern)); }
From source file:Main.java
public static void main(String[] args) { String str1 = "java2s", str2 = "java2s.com"; boolean retval = str1.matches(str2); System.out.println("Value returned = " + retval); retval = str2.matches("com"); System.out.println("Value returned = " + retval); retval = str1.matches("java"); System.out.println("Value returned = " + retval); }
From source file:StringConvenience.java
public static void main(String[] argv) { String pattern = ".*Q[^u]\\d+\\..*"; String line = "Order QT300. Now!"; if (line.matches(pattern)) { System.out.println(line + " matches \"" + pattern + "\""); } else {/* www .j av a 2 s .co m*/ System.out.println("NO MATCH"); } }
From source file:Main.java
public static void main(String[] a) { String zip = "1234-123"; String zipCodePattern = "\\d{5}(-\\d{4})?"; boolean retval = zip.matches(zipCodePattern); }
From source file:Main.java
public static void main(String args[]) { String str = "This is a TEST."; // Use matches() to find any version of test. if (str.matches("(?i).*test.*")) System.out.println("test is in the string."); }
From source file:MainClass.java
public static void main(String args[]) { String zip = "123456"; String zipCodePattern = "\\d{5}(-\\d{4})?"; System.out.println(zip.matches(zipCodePattern)); }