Fix the bug that string.replace will only replace first match

Improve performance
add rainy support