'Declaration
Public Enum SearchExpressionType Inherits System.Enum
'Usage
Dim instance As SearchExpressionType
public enum SearchExpressionType : System.Enum
public enum class SearchExpressionType : public System.Enum
'Declaration
Public Enum SearchExpressionType Inherits System.Enum
'Usage
Dim instance As SearchExpressionType
public enum SearchExpressionType : System.Enum
public enum class SearchExpressionType : public System.Enum
Member | Description |
---|---|
BooleanExpression | Boolean expression with and/or |
DirectoriesOnly | Return directories, do not match text |
FilesOnly | Do not search for text, just match text |
Fuzzy | Levenshtein Fuzzy Match with a maximum difference of 3 edits |
MultilineRegularExpression | Regular expression multi-line match |
PlainText | Plain partial text matching |
RegularExpression | Regular expression matching within a single line |
WholeWord | Match whole word |
using System; using System.Collections.Generic; using KellermanSoftware.FileSearchLibrary; using NUnit.Framework; namespace KellermanSoftware.FileSearchLibraryTests { [TestFixture] public class DocumentationTextMatch { [Test] public void PlainText() { //Setup the search parameters SearchParms parms = new SearchParms(); //This is the directory to search parms.DirectoriesToSearch.Add(@"c:\_git"); //Include all C# files by wildcard parms.FilesToInclude.Add("*.cs"); parms.FileIncludeSearchType = FileSearchType.Wildcard; //Search for a plain text phrase parms.SearchString = "public partial class"; parms.SearchExpressionType = SearchExpressionType.PlainText; //Search with the parameters FileSearchLogic logic = new FileSearchLogic(); List<string> results = logic.SearchFiles(parms); foreach (var filePath in results) { Console.WriteLine(filePath); } } [Test] public void WholeWord() { //Setup the search parameters SearchParms parms = new SearchParms(); //This is the directory to search parms.DirectoriesToSearch.Add(@"c:\_git"); //Include all C# files by wildcard parms.FilesToInclude.Add("*.cs"); parms.FileIncludeSearchType = FileSearchType.Wildcard; //Search for a whole word parms.SearchString = "FirstName"; parms.SearchExpressionType = SearchExpressionType.WholeWord; //Search with the parameters FileSearchLogic logic = new FileSearchLogic(); List<string> results = logic.SearchFiles(parms); foreach (var filePath in results) { Console.WriteLine(filePath); } } [Test] public void BooleanExpression() { //Setup the search parameters SearchParms parms = new SearchParms(); //This is the directory to search parms.DirectoriesToSearch.Add(@"c:\_git"); //Include all C# files by wildcard parms.FilesToInclude.Add("*.cs"); parms.FileIncludeSearchType = FileSearchType.Wildcard; //Search for either FirstName or LastName parms.SearchString = "FirstName or LastName"; parms.SearchExpressionType = SearchExpressionType.BooleanExpression; //Search with the parameters FileSearchLogic logic = new FileSearchLogic(); List<string> results = logic.SearchFiles(parms); foreach (var filePath in results) { Console.WriteLine(filePath); } } [Test] public void Fuzzy() { //Setup the search parameters SearchParms parms = new SearchParms(); //This is the directory to search parms.DirectoriesToSearch.Add(@"c:\_git"); //Include all C# files by wildcard parms.FilesToInclude.Add("*.cs"); parms.FileIncludeSearchType = FileSearchType.Wildcard; //Search for either Orders or Order parms.SearchString = "Orders"; parms.SearchExpressionType = SearchExpressionType.Fuzzy; //Search with the parameters FileSearchLogic logic = new FileSearchLogic(); List<string> results = logic.SearchFiles(parms); foreach (var filePath in results) { Console.WriteLine(filePath); } } [Test] public void RegularExpression() { //Setup the search parameters SearchParms parms = new SearchParms(); //This is the directory to search parms.DirectoriesToSearch.Add(@"c:\_git"); //Include all C# files by wildcard parms.FilesToInclude.Add("*.cs"); parms.FileIncludeSearchType = FileSearchType.Wildcard; //Search lines beginning with public string parms.SearchString = @"^\s*public string"; parms.SearchExpressionType = SearchExpressionType.RegularExpression; //Search with the parameters FileSearchLogic logic = new FileSearchLogic(); List<string> results = logic.SearchFiles(parms); foreach (var filePath in results) { Console.WriteLine(filePath); } } [Test] public void RegularExpressionMultiline() { //Setup the search parameters SearchParms parms = new SearchParms(); //This is the directory to search parms.DirectoriesToSearch.Add(@"c:\_git"); //Include all C# files by wildcard parms.FilesToInclude.Add("*.cs"); parms.FileIncludeSearchType = FileSearchType.Wildcard; //This finds all string functions that return a string parms.SearchString = @"string\s[^\(]+\(string\s[^\)]+\)[\r\n\t\s]+\{"; parms.SearchExpressionType = SearchExpressionType.MultilineRegularExpression; //Search with the parameters FileSearchLogic logic = new FileSearchLogic(); List<string> results = logic.SearchFiles(parms); foreach (var filePath in results) { Console.WriteLine(filePath); } } [Test] public void DirectoriesOnly() { //Setup the search parameters SearchParms parms = new SearchParms(); //This is the directory to search parms.DirectoriesToSearch.Add(@"c:\_git"); //Search for any directory named TestClasses or Tests parms.SearchString = "TestClasses or Tests"; parms.SearchExpressionType = SearchExpressionType.DirectoriesOnly; //Search with the parameters FileSearchLogic logic = new FileSearchLogic(); List<string> results = logic.SearchFiles(parms); foreach (var filePath in results) { Console.WriteLine(filePath); } } [Test] public void FilesOnly() { //Setup the search parameters SearchParms parms = new SearchParms(); //This is the directory to search parms.DirectoriesToSearch.Add(@"c:\_git"); //Search for any file containing Common or Util parms.SearchString = "Common or Util"; parms.SearchExpressionType = SearchExpressionType.FilesOnly; //Search with the parameters FileSearchLogic logic = new FileSearchLogic(); List<string> results = logic.SearchFiles(parms); foreach (var filePath in results) { Console.WriteLine(filePath); } } } }
Option Infer On Imports System Imports System.Collections.Generic Imports KellermanSoftware.FileSearchLibrary Imports NUnit.Framework Namespace KellermanSoftware.FileSearchLibraryTests <TestFixture> Public Class DocumentationTextMatch <Test> Public Sub PlainText() 'Setup the search parameters Dim parms As New SearchParms() 'This is the directory to search parms.DirectoriesToSearch.Add("c:\_git") 'Include all C# files by wildcard parms.FilesToInclude.Add("*.cs") parms.FileIncludeSearchType = FileSearchType.Wildcard 'Search for a plain text phrase parms.SearchString = "public partial class" parms.SearchExpressionType = SearchExpressionType.PlainText 'Search with the parameters Dim logic As New FileSearchLogic() Dim results As List(Of String) = logic.SearchFiles(parms) For Each filePath In results Console.WriteLine(filePath) Next filePath End Sub <Test> Public Sub WholeWord() 'Setup the search parameters Dim parms As New SearchParms() 'This is the directory to search parms.DirectoriesToSearch.Add("c:\_git") 'Include all C# files by wildcard parms.FilesToInclude.Add("*.cs") parms.FileIncludeSearchType = FileSearchType.Wildcard 'Search for a whole word parms.SearchString = "FirstName" parms.SearchExpressionType = SearchExpressionType.WholeWord 'Search with the parameters Dim logic As New FileSearchLogic() Dim results As List(Of String) = logic.SearchFiles(parms) For Each filePath In results Console.WriteLine(filePath) Next filePath End Sub <Test> Public Sub BooleanExpression() 'Setup the search parameters Dim parms As New SearchParms() 'This is the directory to search parms.DirectoriesToSearch.Add("c:\_git") 'Include all C# files by wildcard parms.FilesToInclude.Add("*.cs") parms.FileIncludeSearchType = FileSearchType.Wildcard 'Search for either FirstName or LastName parms.SearchString = "FirstName or LastName" parms.SearchExpressionType = SearchExpressionType.BooleanExpression 'Search with the parameters Dim logic As New FileSearchLogic() Dim results As List(Of String) = logic.SearchFiles(parms) For Each filePath In results Console.WriteLine(filePath) Next filePath End Sub <Test> Public Sub Fuzzy() 'Setup the search parameters Dim parms As New SearchParms() 'This is the directory to search parms.DirectoriesToSearch.Add("c:\_git") 'Include all C# files by wildcard parms.FilesToInclude.Add("*.cs") parms.FileIncludeSearchType = FileSearchType.Wildcard 'Search for either Orders or Order parms.SearchString = "Orders" parms.SearchExpressionType = SearchExpressionType.Fuzzy 'Search with the parameters Dim logic As New FileSearchLogic() Dim results As List(Of String) = logic.SearchFiles(parms) For Each filePath In results Console.WriteLine(filePath) Next filePath End Sub <Test> Public Sub RegularExpression() 'Setup the search parameters Dim parms As New SearchParms() 'This is the directory to search parms.DirectoriesToSearch.Add("c:\_git") 'Include all C# files by wildcard parms.FilesToInclude.Add("*.cs") parms.FileIncludeSearchType = FileSearchType.Wildcard 'Search lines beginning with public string parms.SearchString = "^\s*public string" parms.SearchExpressionType = SearchExpressionType.RegularExpression 'Search with the parameters Dim logic As New FileSearchLogic() Dim results As List(Of String) = logic.SearchFiles(parms) For Each filePath In results Console.WriteLine(filePath) Next filePath End Sub <Test> Public Sub RegularExpressionMultiline() 'Setup the search parameters Dim parms As New SearchParms() 'This is the directory to search parms.DirectoriesToSearch.Add("c:\_git") 'Include all C# files by wildcard parms.FilesToInclude.Add("*.cs") parms.FileIncludeSearchType = FileSearchType.Wildcard 'This finds all string functions that return a string parms.SearchString = "string\s[^\(]+\(string\s[^\)]+\)[\r\n\t\s]+\{" parms.SearchExpressionType = SearchExpressionType.MultilineRegularExpression 'Search with the parameters Dim logic As New FileSearchLogic() Dim results As List(Of String) = logic.SearchFiles(parms) For Each filePath In results Console.WriteLine(filePath) Next filePath End Sub <Test> Public Sub DirectoriesOnly() 'Setup the search parameters Dim parms As New SearchParms() 'This is the directory to search parms.DirectoriesToSearch.Add("c:\_git") 'Search for any directory named TestClasses or Tests parms.SearchString = "TestClasses or Tests" parms.SearchExpressionType = SearchExpressionType.DirectoriesOnly 'Search with the parameters Dim logic As New FileSearchLogic() Dim results As List(Of String) = logic.SearchFiles(parms) For Each filePath In results Console.WriteLine(filePath) Next filePath End Sub <Test> Public Sub FilesOnly() 'Setup the search parameters Dim parms As New SearchParms() 'This is the directory to search parms.DirectoriesToSearch.Add("c:\_git") 'Search for any file containing Common or Util parms.SearchString = "Common or Util" parms.SearchExpressionType = SearchExpressionType.FilesOnly 'Search with the parameters Dim logic As New FileSearchLogic() Dim results As List(Of String) = logic.SearchFiles(parms) For Each filePath In results Console.WriteLine(filePath) Next filePath End Sub End Class End Namespace
System.Object
System.ValueType
System.Enum
KellermanSoftware.FileSearchLibrary.SearchExpressionType
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2