Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search for all files containing 2 specific strings?

In my Visual Studio I'd like to find all the files that contain 2 specific words (say, UpdatePanel and DropDownCheckList in a solution or project). In other words, I like to find all the files using my home-made webserver control DropDownCheckList with the ASP.NET control UpdatePanel.

how to find all files containing 2 specific words

How to do it?

like image 314
Fulproof Avatar asked Oct 26 '25 20:10

Fulproof


1 Answers

The answer depends on your Visual Studio Version. Since VS 2013 they use .net regexes in their search dialogue, so the solution would look something like:

^(?s)(?=.*Foobar)(?=.*Test)

(?=...) is a lookahead assertion

(?s) is an inline modifier to make the . matches also newline characters

with an older version, there is a special kind of regex flavour used, so you can not use lookaheads:

(Foobar(.|\n)+Test)|(Test(.|\n)+Foobar)

here I used an alternation to match first word A, then word B OR first word B then word A.

(.|\n)+ is a workaround to match either any character or a newline character.

like image 190
stema Avatar answered Oct 28 '25 10:10

stema