echo 'ax&bx&xx&dx' | perl -wnE 'say "$1$2" if /(a[^&]*)(?:.*?(&c[^&]*))?/'