Clone RegExp flags and set `lastIndex` if needed.

Closes #22.