2013-06-03 19 views
0

我需要在文件中搜索輸入字段中輸入的表達式,並將結果以的格號返回前後字符數和粗體表達式。 我不知道有一次我使用javascript的search()函數如何返回結果,知道該命令的結果是位置。 到目前爲止,我只有這個:在文件中搜索並使用Javascript進行顯示

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*/ 
+0

1+沒有人的去爲你寫。 – vikas

+0

我很樂意幫助你,但問題很模糊,我不完全明白你想達到什麼目的。 – BrunoLM

+0

我需要在文件中查找某個表達式並顯示該表達式的所有出現。例如 : file.txt: Lorem ipsum dolor sit amet。 表達式搜索: ipsum 我需要在div中顯示錶達式和前後5個字符: orem ipsum dolo – Lou

回答

0

這是我做的:

string.substring(beginning,end); 
相關問題