我正在使用下面的 jQuery 代码来搜索页面上的文本,但这不会搜索网页上的法语或其他语言文本。使用的jQuery代码如下 -
phrase = ["\\b(", phrase, ")"].join("");
//search for any matches
var count = 0;
$("#faq-container p").each(
function (i, v) {
//replace any matches
var block = $(v);
block.html(
block.text().replace(
//new RegExp(phrase, "gi"), function (match) { // properties used g , i => g -> global : Whether to test the regular expression against all possible matches in a string, or only against the first.
// i -> ignoreCase : Whether to ignore case while attempting a match in a string.
phrase, function (match) {
count++;
return ["<span class='highlight'>", match, "</span>"].join("");
}
)
);
}
);