从xaxaxcxaxcx中正则匹配a和c之间的内容

假设一段文本形如:xaxaxcxaxcx
其中x表示除a和c之外的其他任意长度字符
我要匹配a和c之间的内容,只希望得到两个axc的结果,不希望得到axaxc这样的结果,该如何写正则表达式,谢谢

public int countYZ(String a) {
int sum=0;
a=a.toLowerCase();

    Pattern p = Pattern.compile("a[^ac]c");
    Matcher m = p.matcher(a);

    while(m.find()) {

    sum++;
   }

如果要输出的话好像是要正则表达式的捕获工具,因为用正则的话是只能输出整条String的,所以如果不是非要用正则的话你可以用substring

String p = "a[^a]c";

(?<=a)x(?=c)