Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

looking for advanced find for source code

Status
Not open for further replies.

Statey603

Programmer
Nov 10, 2009
196
US
I am not sure where to post this but am hoping that perhaps fellow c# developers might be able to help.

I am wondering if anyone knows of search tools or code/text editors that have advanced serach/find capabilities. I am trying to search a large number of source files for lines of code containing "service auth" or "service_auth" and NOT containing the text "ALL".

It seems the built-in find only can search for a single, specific pattern and cannot exclude any patterns. I can't figure out how to search for "service auth" and "service_auth" at the same time and more importantly to specify to also exclude any line with "ALL" in it.

I am hoping to find something with capabilities like web searching where you can use a dash to indicate 'exclude'. For example, in the google search field, I might enter
[service auth service_auth -ALL] to get the results that I want.

Does anyone know of a way to do this type of advanced searching/parsing in Visual Studio or perhaps with a 3rd party text editor or search tool?

I appreciate any suggestions.
 
besides, finding files with this text,what exactly are your trying to do? Or, what ultimately is your goal. I have an idea or two, but don't want to presume anything.

as for advanced searching: I would try a search tool outside of VS. this would at least give you a list of the files. then you could open them in VS and do what it is you need to.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
I am simply trying to identify instances of lines of code with the specified text because it needs to be modified.

My my eventual goal is to locate and replace, but first I need to look at the results to see the variations. This code was worked on by too many people before me.

FYI: There are thousands of lines with "service auth" or "service_auth". About 1/2 of them also have "ALL". I only want the ones that do not contain "ALL" (for now anyway).

I am contemplating using a Windows version of awk but it has been a decade or so since I used it and am hoping that there might be a good 3rd party editor or tool that has these capabilities.


 
You can enable regex searching with VS, but i'm not sure how powerful the regex is. it's worth a shot though.

Moving forward I would recommend the VS plug-in Rehsharper (R#). It a refactoring tool that I cannot say enough good things about. It removes the need for find and replace by doing it for you. but really it's so much more than find/replace.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Statey,

I find Agent Ransack extremely valuable. Supports simple search for strings in files through to regex. The preview pane shows the lines where your search was found.

It's a freebie if you google for the download.

Hth,

MadJock

"Just beacuse you're paranoid, don't mean they're not after you
 
I'd go with jmeckley's suggestion of the Visual Studio RegEx search.

1. In Visual Studio press Ctrl+Shift+F< for the Find dialog window.
2. Under Find options tick the Use checkbox and make sure Regular expressions is selected.
3. In the Find what box type in the regular expression something like ^.+service[_|\s]auth.+$
4. Click Find.

The regular expression above doesn't exclude the word "ALL", to do this I would need more info from you; where would ALL appear, before or after or anywhere in the line? Could you give an example?

Pete
 
Thanks....

I have downloaded Agent Ransack for my immediate needs with searching for PowerBuilder.

I will investigate the RegEx searching in Visual Studio next time I am need tyo use Visual Studio.

I appreciate the suggestions and information.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top