$ perl -e'$_="abcabcdabc";while(/(?g)(a[^a]+)/){print "$1\n"}' abc abcd abc