eclipse 简单的eclipse搜索问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4965551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:45:54  来源:igfitidea点击:

Simple eclipse search problem

eclipsesearch

提问by u123

I use the eclipse File Search option very much to search all files in my workspace for a certain content. But how do I specify that it should only return hits from a fixed search criteria? As an example I would like to find all occurrences of the string:

我经常使用 eclipse 文件搜索选项来搜索我工作区中的所有文件以查找某个内容。但是我如何指定它应该只返回来自固定搜索条件的命中?例如,我想查找所有出现的字符串:

com.mystuff.data

but I also get all the hits for:

但我也得到了所有的点击:

com.mystuff.data.ui

How do I make a "this-string-only-search" when searching files in my workspace??

在我的工作区中搜索文件时如何进行“仅此字符串搜索”?

回答by xyz

If I understand you correctly, Eclipse don't provide option to search exact word. You can use regular expression for it.
You can use \bSearchKeyword\bto find exact word.

如果我理解正确,Eclipse 不提供搜索确切单词的选项。您可以使用正则表达式。
您可以使用\bSearchKeyword\b来查找确切的单词。

回答by Samar Hossam

I suggest that you use regular expressions.

我建议你使用正则表达式

Here are the steps:

以下是步骤:

  1. Selectthe checkbox "Regular expression"which is located beside the "Containing text" field.
  2. In the "Containing text"field write: com.mystuff.data\D\W
  1. 选中位于“包含文本”字段旁边的复选框“正则表达式”
  2. “包含文本”字段中写入:com.mystuff.data\D\W

Note that:

注意:

  • \Dmeans "no digit"
  • \Wmeans "no alphanumeric"
  • In case you would like to refine the regular expression, click Ctrl-SPACE, in order to get the regular expression assistance.
  • \D表示“无数字”
  • \W表示“无字母数字”
  • 如果您想优化正则表达式,请单击Ctrl-SPACE以获得正则表达式帮助。

Hope this helps.

希望这可以帮助。

Best regards

此致

回答by Paul Gobée

Maybe slightly off-topic but this got me tripped and brought me here - maybe useful for somebody else:

也许有点跑题,但这让我绊倒并将我带到这里 - 也许对其他人有用:

  • In the Eclipse standard Find/Replace dialogue the section 'Options' (that includes the option 'Whole Word') may be hidden if the Find/Replace dialogue window was previously resized to a smaller size, without any clue to its presence. Resizing it larger brings back the options section. See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=355206and attached shots.Eclipse Find/Replace dialogue window resized with options hiddenFull size Find/Replace Dialogue WITH options
  • Eclipse standard Find/Replace dialogue search for Whole Word regards several characters (including period) besides a space as a word delimiter, so you indeed cannot distinguish between "com.mystuff.data" and "com.mystuff.data.ui"
    E.g. search 'Stack' with option 'Whole Word' checked:
    willmatch:

    • Stack
    • Stack overflow
    • Stack.overflow
    • Stack,overflow
    • Stack[overflow]
    • Stack(overflow)
    • Stack-overflow
    • Stack/overflow

    will notmatch:

    • Stackoverflow
    • Stack2overflow
    • Stack_overflow
  • 在 Eclipse 标准的查找/替换对话框中,如果查找/替换对话框窗口之前被调整为较小的尺寸,而没有任何线索表明它的存在,则可能隐藏“选项”部分(包括选项“整个单词”)。将其放大会带回选项部分。请参阅:https: //bugs.eclipse.org/bugs/show_bug.cgi?id=355206和附加截图。Eclipse 查找/替换对话窗口调整大小并隐藏选项全尺寸查找/替换对话选项
  • Eclipse 标准的 Find/Replace 对话搜索 Whole Word 将除空格之外的几个字符(包括句点)视为单词分隔符,因此您确实无法区分“com.mystuff.data”和“com.mystuff.data.ui”
    例如搜索选中“全字”选项的“堆栈”:
    匹配:

    • 堆栈溢出
    • 堆栈溢出
    • 堆栈溢出
    • 堆栈溢出]
    • 堆栈溢出)
    • 堆栈溢出
    • 堆栈溢出

    不会匹配:

    • 堆栈溢出
    • 堆栈溢出
    • 堆栈溢出

回答by Pramod Shivale

Simplest way is to add space in the start and end of your search term.

最简单的方法是在搜索词的开头和结尾添加空格。

回答by Rinat Tainov

Try SHFT+ CTRL+R, then on right upper angle select Working Set, then name and specify your resources.

尝试SHFT+ CTRL+ R,然后在右上角选择工作集,然后命名并指定你的资源。

Create Work Set as above, then CTRL+Hcheck checkbox All occurency, then select your Work Set. Or maybe you can create work set in CTRL+H.

如上所述创建工作集,然后CTRL+H选中所有出现的复选框,然后选择您的工作集。或者您可以在CTRL+ 中创建工作集H