This won't work because $ifmatch is reset by $iif() so it doesn't hold $mid($1,%pos,8) anymore.