We can avoid double escaping by using `StringUtils.regexEscape()`. It would be nice to split this regex into multiple lines.

This regex should be moved into a core file so it can be shared with the InlineColorEditor. All of the bugs fixed here apply to the Inline Color Editor as well.