import java.util.regex.Matcher;import java.util.regex.Pattern;public class PatternDemo {/** * @param args */public static void main(String[] args) {String str = ",a b c,a,c";Pattern pattern = Pattern.compile("a[^,]*c");Matcher matcher = pattern.matcher(str);while(matcher.find()){System.out.println(matcher.group());}}}