fix regex expression scope bug