如何在JavaScript中转义正斜杠'/'来查询lucene?

时间:2015-11-02 15:44:19

标签: javascript regex lucene

当我尝试这个时:

'cable/agency'.replace(/\//, '\/');

我明白了:

'cable/agency'

如果我试试这个:

'cable/agency'.replace(/\//, '\\/');

或者这个:

'cable/agency'.replace(/\//, '\\\/');

我明白了:

processedString cable\/agency
FilterTypes.js:51 processedString cable\\/agency
FilterTypes.js:51 processedString cable\\\/agency
FilterTypes.js:51 processedString cable\\\\/agency
FilterTypes.js:51 processedString cable\\\\\/agency
FilterTypes.js:51 processedString cable\\\\\\/agency

等,直到超过调用堆栈。

0 个答案:

没有答案