Repaired regexp function