bvaughn / highlight-words-core

Utility functions shared by react-highlight-words and react-native-highlight-words

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

There is a case that cannot be resolved

paper opened this issue · comments

commented

const textToHighlight = "This is C++ some text to highlight."
const searchWords = ["This", "i", "C++"];

==》

SyntaxError
Invalid regular expression: /C++/: Nothing to repeat
eval
https://n9544l.csb.app/node_modules/highlight-words-core/dist/index.js:180:18
defaultFindChunks
https://n9544l.csb.app/node_modules/highlight-words-core/dist/index.js:173:5
findAll
https://n9544l.csb.app/node_modules/highlight-words-core/dist/index.js:112:16
$csb$eval
/src/index.js:5:23
2 |
3 | const textToHighlight = "This is C++ some text to highlight."
4 | const searchWords = ["This", "i", "C++"];

5 | const chunks = findAll({
| ^
6 | caseSensitive: false,
7 | searchWords,
8 | textToHighlight

Check out the docs. You'll want to pass autoEscape: true to findAll.