garysieling / garysieling/jquery-highlighttextarea
Words with vertical bar ('|') does not highlight
- Dominant language
- JavaScript
- Stars
- 157
- Forks
- 72
- PR merge metrics
- No merged PRs in 30d
Description
If you set the word to highlight to something like '|a', it doesn't work (that's a vertical bar and not a letter).
I've investigated this problem and found two places where it was problematic:
1) I had to use the regular expression for the word such that "|a" became "[|]a". This works such that the initial part of the plugin code matches "|a" in the text area.
2) The second part of the plugin code that actually searches for the match, "|a", to highlight fails because the "|" interferes with the regex being constructed in this line of code:
``` javascript
text = text.replace(new RegExp(match, 'g'), '$&', 'g');
```
Can you fix this? Inserting this line before the above line seems to fix it for me:
``` javascript
match = match.replace('|','[|]');
```
Thanks.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.