package java_20180209_api_string;import java.util.regex.Matcher;import java.util.regex.Pattern;public class RegexDemo1 { public static void main(String[] args) { String reg="a[bef]c"; String s="abc"; System.out.println(s.matches(reg)); System.out.println("abcjdkjkaeckdkdafclli".replaceAll(reg,"X")); Pattern p=Pattern.compile(reg); Matcher m=p.matcher("abcjdkjkaeckdkdafclli"); while (m.find()) { System.out.println(m.start()); } System.out.println(m.find()); System.out.println(m.group()); }}