Optimization of preg calls