Match TRCK and TPOS using regex and reduce code redundancy.