最佳答案
迭代所有行并检查indexOf
原文链接:https://www.f2er.com/js/429793.htmlfunction findFooLineNumbers(editor,foo) {
var lines = editor.session.doc.getAllLines()
var fooLineNumbers = []
for (var i = 0,l = lines.length; i < l; i++) {
if (lines[i].indexOf(foo) != -1)
fooLineNumbers.push(i)
}
return fooLineNumbers
}