日期:2014-05-20 浏览次数:20597 次
import java.util.regex.Pattern; public class Test { public static void main(String[] args) { String[] strs = { "asdf,我们,你们,他们", "我们,asdf,你们,他们", "我们,你们,他们,asdf", "你们,他们, 我们,asdf", "你们,他们, 我,asdf" }; Pattern pattern = Pattern.compile("(?=.*你们)(?=.*我们)(?=.*他们).*"); for (String str : strs) { System.out.printf("%s: %s%n", str, pattern.matcher(str).matches()); } } }