Fixed array indices for finding the element from regex groups. Fixed the remainder replacements to use the correct indices.