RegEx1.java
Select all
/* RegEx1.java David Klick 3/30/05 Demonstrates regular expression use. */ import java.util.regex.*; public class RegEx1 { public static void main(String[] args) { String[] sarr = { "I do not like green eggs and ham", "I do not like them Sam I am", "I do not like them here or there", "I do not like them anywhere", "Imagine", "whatever", "One fish", "Two fish", "Red fish", "Blue fish" }; Pattern p = Pattern.compile("^I.*e$"); Matcher m; System.out.println(p.pattern()); for (int i=0; i