RegExp optimizations