Regex Pattern Structure Javascript For Loop