lib/re: fix offset of submatches and clarify variables name