Pattern: compile('[a-z]+') : Pattern « java.util.regex « Java by API
- Java by API
- java.util.regex
- Pattern
Pattern: compile('[a-z]+')
/*
* Output:
Match: www
Match: java
Match: s
Match: com
* */
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MainClass {
public static void main(String args[]) {
// Match lowercase words.
Pattern pat = Pattern.compile("[a-z]+");
Matcher mat = pat.matcher("www.java2s.com.");
while (mat.find())
System.out.println("Match: " + mat.group());
}
}
Related examples in the same category