package com.mingrisoft;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MyApp{
public static void main(String[] args) {
String regex="[a-zA-Z]{4,}";
String input="As people living45 standard rise, leisure and entertainment game begins to be";
Matcher matcher=null;
Pattern pattern=Pattern.compile(regex);
matcher=pattern.matcher(input);
while(matcher.find()){
String a=matcher.group();
System.out.println(a);
}
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MyApp{
public static void main(String[] args) {
String regex="[a-zA-Z]{4,}";
String input="As people living45 standard rise, leisure and entertainment game begins to be";
Matcher matcher=null;
Pattern pattern=Pattern.compile(regex);
matcher=pattern.matcher(input);
while(matcher.find()){
String a=matcher.group();
System.out.println(a);
}
}}
效果:
people
living
standard
rise
leisure
entertainment
game
begins