OnJava8-Examples/strings/ReFlags.java

21 lines
469 B
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// strings/ReFlags.java
2015-06-15 17:47:35 -07:00
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());
}
2015-09-07 11:44:36 -06:00
}
/* Output:
2015-06-15 17:47:35 -07:00
java
Java
JAVA
2015-09-07 11:44:36 -06:00
*/