Fix issue #6 mentioned in KayK / RegexHighlightView

Address the two issues in the comment:
https://github.com/KayK/RegexHighlightView/issues/6#issuecomment-1130667
6