Whatever may to the total number of matching outcomes
If your variable is a
use __V for getting last occurrence using
${__V(a_${a_matchNr})}
or __evalVar
${__evalVar(a_${a_matchNr})}
a_matchNr return last number
refName_matchNr - the number of matches found; could be 0