开发者

Simple eclipse search problem

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 occurrenc开发者_StackOverflow中文版es 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??


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.


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


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.

    Simple eclipse search problem

    Simple eclipse search problem

  • 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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜