Improve replacement command

- [X] Check input regexp is valud, and don't evaluate it if it is invalid
- [ ] Care case for replacement commands.