OnJava8-Examples/strings/ReFlags.java
2015-04-20 15:36:01 -07:00

20 lines
474 B
Java

//: strings/ReFlags.java
import java.util.regex.*;
public class ReFlags {
public static void main(String[] args) {
Pattern p = Pattern.compile("^java",
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
Matcher m = p.matcher(
"java has regex\nJava has regex\n" +
"JAVA has pretty good regular expressions\n" +
"Regular expressions are in Java");
while(m.find())
System.out.println(m.group());
}
} /* Output:
java
Java
JAVA
*///:~