0

我需要在文件中搜索在输入字段中输入的表达式,并在 div 中返回结果,其中前后有n个字符,表达式以粗体显示。我不知道一旦我使用了 javascript 的 search() 函数如何返回结果,知道该命令的结果就是位置。到目前为止,我只有这个:

var length = expr.legth;/*get the length of the expression searched*/
var indexString = docSearched.search(expression);/*get the position of the expression in the document*/

现在我需要这样的东西:

var el = document.getElementById('content'); 
    el.innerHTML = docSearched[indexString];/*display the all the occurence of the searched expression*/
4

1 回答 1

0

我是这样做的:

string.substring(beginning,end);
于 2013-06-04T07:28:28.910 回答