optimized string mapper for regular expressions