search()
有没有人知道javascript中用于函数的算法是什么?
var myRegExp = /Alex/;
var string1 = "Today John went to the store and talked with Alex.";
var matchPos1 = string1.search(myRegExp);
if(matchPos1 != -1)
document.write("There was a match at position " + matchPos1);
else
document.write("There was no match in the first string");
我需要使用此函数在文本文档中搜索不同的字符串值。但是我需要记录下这个方法背后的算法是什么,复杂性是什么。否则,我必须编写自己的方法来搜索我拥有的文本文件。