autoComplete.js 输入左括号时出现未终止组错误
autoComplete.js Unterminated group error when typing an opening parenthesis
我正在尝试实施 autoComplete.js on this site: http://bydaylight.com/testing/patent-defenses/
我们数据中的一些术语有这样的括号:
112(1/a)
当我开始输入那个确切的字符串时,我在输入左括号后收到错误消息
Uncaught (in promise) SyntaxError: Invalid regular expression: /112(/: Unterminated group
autocomplete.js error screenshot
数据本身只是一个简单的数组。看起来像这样:
["100", "101", "112", "119", "120", "135", "273", "287", "295", "365", "102(e) ", "112(1/a)", "112(2/b)", "112(4/d)", "112(6/f) ", "271(a)", "271(b)", "271(c) ", "271(e) ", "271(f) ", "271(g)", "abatement", "ACQUIESCENCE", "admitted prior art", "Alice"]
我需要考虑任何特殊格式吗?只是在寻找一些指导。
您收到该错误是因为 autoComplete.js
在 strict
模式下的匹配方法是正则表达式,它与括号冲突,因为它被认为是无效字符,应该在正则表达式模式中进行转义。
所以您现在有两种选择来解决您的问题:
- 使用
loose
模式代替strict
- 在通过
query
处理之前转义无效字符
我正在尝试实施 autoComplete.js on this site: http://bydaylight.com/testing/patent-defenses/
我们数据中的一些术语有这样的括号:
112(1/a)
当我开始输入那个确切的字符串时,我在输入左括号后收到错误消息
Uncaught (in promise) SyntaxError: Invalid regular expression: /112(/: Unterminated group
autocomplete.js error screenshot
数据本身只是一个简单的数组。看起来像这样:
["100", "101", "112", "119", "120", "135", "273", "287", "295", "365", "102(e) ", "112(1/a)", "112(2/b)", "112(4/d)", "112(6/f) ", "271(a)", "271(b)", "271(c) ", "271(e) ", "271(f) ", "271(g)", "abatement", "ACQUIESCENCE", "admitted prior art", "Alice"]
我需要考虑任何特殊格式吗?只是在寻找一些指导。
您收到该错误是因为 autoComplete.js
在 strict
模式下的匹配方法是正则表达式,它与括号冲突,因为它被认为是无效字符,应该在正则表达式模式中进行转义。
所以您现在有两种选择来解决您的问题:
- 使用
loose
模式代替strict
- 在通过
query
处理之前转义无效字符