Fixed replacement, added pattern cache

The replacement now uses lookahead and lookbehind to account for
detection of surrounding whitespace without eating it. Replaced the
Emoticons with surrogate pairs (Android 4.3 compatibility?).

Also added a pattern cache for regex precompilation.