fix regex logic; TODO: Add test suite to ensure proper regex functionality to avoid in future