// Ivan Novick // Jan 26, 2008 // // use the regular expression match function in the String class class string_match { public static void main(String args[]) { String s = "Hello World"; // match any string that startswith 0 or more characters followed by 'll' followed by 0 or more characters // This condition is true if (s.matches(".*ll.*")) { System.out.println("match .*ll.*"); } // match any string that startswith 0 or more characters followed by 'LL' followed by 0 or more characters // This condition is false if (s.matches(".*LL.*")) { System.out.println("match .*LL.*"); } // match any string that startswith 'H" // This condition is true if (s.matches("H.*")) { System.out.println("match H.*"); } } }