kvm: extract a regexp matching out of a for loop