5

I am searching for all occurrences of an out of date email domain in my codebase on TFS. Specifically, I am searching for "@testexample.com". However, the search seems to completely ignore the "@" symbol.

If I search "@testexample.com", I get all occurrences of "testexample.com". I have also tried "*@testexample.com" but prefix wildcards aren't allowed in code search.

ChasetopherB
  • 466
  • 9
  • 23
  • Vote on my feature request here: https://developercommunity.visualstudio.com/idea/893393/allow-non-alphanumeric-characters-in-code-search.html – csrowell Jan 22 '20 at 15:32

1 Answers1

6

That's not supported.

Checked for some characters in code search. You can't use the symbol characters except * and ? as part of your search query, which including below characters: . , : ; / \ ` ' " @ = ! # $ & + ^ | ~ < > ( ) { } [ ]. The search will simply ignore these symbols.

But you can use wildcard characters * and ? to broaden your search.

You can use wildcard characters anywhere in your search string except as a prefix in a simple search string or a query that uses a code type filter. For example, you cannot use a search query such as *RequestHandler or class:?RequestHandler. However, you can use prefix wildcards with the other search filter functions; for example, the search query strings file:*RequestHandler.cs and repo:?Handlers are valid.

Please see Broaden your search with wildcards for details.

If you want to search the strings including these symbol exactly(such as '@' here), you can code search with other strings (eg, testexample.com here) to narrow down the scope first, then copy the specific code to text editor which support the symbols (eg, Notepad++), then search stings with the symbol characters.

Besides, if you are using Git, another workaround is using the code search tool Hound: a lightning fast code search tool, it supports the symbol characters. Reference this thread to use it: How can I publish source code (Visual Studio) on a intranet?

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
  • I can indeed confirm that searching on special characters like "[" for instance, does not work on an on premise Tfs2018 instance. I am however intrigued why searching on the exact same string works on VSTS? I would have expected it to work, seeing that the official Microsoft documentation states that it should work for these versions (VSTS | TFS 2018 | TFS 2017) https://learn.microsoft.com/en-us/vsts/project/search/advanced-code-search-syntax?view=vsts – Morné Kruger Jul 02 '18 at 09:14