Google Chrome浏览器中区分大小写的搜索


44

有没有一种方法可以对Google Chrome浏览器中的网页进行区分大小写?

浏览器的屏幕截图

假设我要搜索“树”,并且想排除所有与我要查找的情况不匹配的变体,例如“树”或“树”。这可能吗?


1
XP的美好时光...
Luke Fisk-Lennon

我注意到这是8年前问的。有人知道这是否可能吗?
蒂姆(Tim)

Answers:



2

Chrome中的开发者工具支持区分大小写的搜索。

打开当前选项卡的开发人员工具(Ctrl+ Shift+ I–大写的“ i”),然后打开“跨所有源搜索(Ctrl+ Shift+ F)”,然后选择“区分大小写”。

如果区分大小写还不够,它还支持正则表达式。


1

这是一个提示输入单词并执行区分大小写的搜索的函数:

var searches = searches || 0;

(function () {
var count = 0,
    text;
text = prompt('Search:', '');
if (text == null || text.length === 0) return;

function searchWithinNode(node, re) {
    var pos, skip, acronym, middlebit, endbit, middleclone;
    skip = 0;
    if (node.nodeType === 3) {
        pos = node.data.search(re);
        if (pos >= 0) {
            acronym = document.createElement('ACRONYM');
            acronym.title = 'Search ' + (searches + 1) + ': ' + re.toString();
            acronym.style.backgroundColor = backColor;
            acronym.style.borderTop = '1px solid ' + borderColor;
            acronym.style.borderBottom = '1px solid ' + borderColor;
            acronym.style.fontWeight = 'bold';
            acronym.style.color = borderColor;
            middlebit = node.splitText(pos);
            endbit = middlebit.splitText(RegExp.lastMatch.length);
            middleclone = middlebit.cloneNode(true);
            acronym.appendChild(middleclone);
            middlebit.parentNode.replaceChild(acronym, middlebit);
            count++;
            skip = 1;
        }
    } else if (node.nodeType == 1 && node.childNodes && node.tagName.toUpperCase() != 'SCRIPT' && node.tagName.toUpperCase != 'STYLE') for (var child = 0; child < node.childNodes.length; ++child) child = child + searchWithinNode(node.childNodes[child], re);
    return skip;
}
var borderColor = '#' + (searches + 8).toString(2).substr(-3).replace(/0/g, '3').replace(/1/g, '6');
var backColor = borderColor.replace(/3/g, 'c').replace(/6/g, 'f');
if (searches % 16 / 8 >= 1) {
    var tempColor = borderColor;
    borderColor = backColor;
    backColor = tempColor;
}
searchWithinNode(document.body, text);
window.status = 'Found ' + count + ' match' + (count == 1 ? '' : 'es') + ' for ' + text + '.';
if (count > 0) searches++;
})();

可以将其另存为书签以便于访问。

参考文献

正则表达式搜索书签

突出显示正则表达式书签




By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.