Pattern: compile('[a-z]+') : Pattern « java.util.regex « Java by API






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

1.Pattern.CANON_EQ
2.Pattern.CASE_INSENSITIVE
3.Pattern: compile('d.*ian')
4.Pattern: compile('(\\w+)\\s(\\d+)')
5.Pattern: compile('e.+?d')
6.Pattern: compile(String text)
7.Pattern: matcher(String text)
8.Pattern: split(String str)