Simple eclipse search problem

Deadly 提交于 2019-12-21 03:49:48

问题


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:

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??


回答1:


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\b to find exact word.




回答2:


I suggest that you use regular expressions.

Here are the steps:

  1. Select the checkbox "Regular expression" which is located beside the "Containing text" field.
  2. In the "Containing text" field write: com.mystuff.data\D\W

Note that:

  • \D means "no digit"
  • \W means "no alphanumeric"
  • In case you would like to refine the regular expression, click Ctrl-SPACE, in order to get the regular expression assistance.

Hope this helps.

Best regards




回答3:


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=355206 and attached shots.

  • 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:
    will match:

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

    will not match:

    • Stackoverflow
    • Stack2overflow
    • Stack_overflow



回答4:


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




回答5:


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

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



来源:https://stackoverflow.com/questions/4965551/simple-eclipse-search-problem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!