Strings.Filter Yöntem
Tanım
Belirtilen filtre ölçütlerine göre bir dizinin alt kümesini içeren sıfır tabanlı bir dizi döndürür String .Returns a zero-based array containing a subset of a String array based on specified filter criteria.
Aşırı Yüklemeler
| Filter(Object[], String, Boolean, CompareMethod) |
Belirtilen filtre ölçütlerine göre bir dizinin alt kümesini içeren sıfır tabanlı bir dizi döndürür |
| Filter(String[], String, Boolean, CompareMethod) |
Belirtilen filtre ölçütlerine göre bir dizinin alt kümesini içeren sıfır tabanlı bir dizi döndürür |
Filter(Object[], String, Boolean, CompareMethod)
Belirtilen filtre ölçütlerine göre bir dizinin alt kümesini içeren sıfır tabanlı bir dizi döndürür String .Returns a zero-based array containing a subset of a String array based on specified filter criteria.
public static string[]? Filter (object?[] Source, string? Match, bool Include = true, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
public static string[] Filter (object[] Source, string Match, bool Include = true, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
static member Filter : obj[] * string * bool * Microsoft.VisualBasic.CompareMethod -> string[]
Public Function Filter (Source As Object(), Match As String, Optional Include As Boolean = true, Optional Compare As CompareMethod = Microsoft.VisualBasic.CompareMethod.Binary) As String()
Parametreler
- Source
- Object[]
Gereklidir.Required. Aranacak dizelerin tek boyutlu dizisi.One-dimensional array of strings to be searched.
- Match
- String
Gereklidir.Required. Aranacak dize.String to search for.
- Include
- Boolean
İsteğe bağlı.Optional. Boolean dahil edilen veya hariç tutulacak alt dizelerin döndürülüp döndürülmeyeceğini belirten değer Match .Boolean value indicating whether to return substrings that include or exclude Match. Includeİse True , Filter işlev alt dize olarak içeren dizinin alt kümesini döndürür Match .If Include is True, the Filter function returns the subset of the array that contains Match as a substring. Includeİse False , Filter işlev alt dize olarak içermeyen dizinin alt kümesini döndürür Match .If Include is False, the Filter function returns the subset of the array that does not contain Match as a substring.
- Compare
- CompareMethod
İsteğe bağlı.Optional. Kullanılacak dize karşılaştırma türünü gösteren sayısal değer.Numeric value indicating the kind of string comparison to use. Değerler için "Ayarlar"a bakın.See "Settings" for values.
Döndürülenler
- String[]
Belirtilen filtre ölçütlerine göre bir dizinin alt kümesini içeren sıfır tabanlı bir dizi String .A zero-based array containing a subset of a String array based on specified filter criteria.
Özel durumlar
Source , Nothing tek boyutlu bir dizi değil.Source is Nothing or is not a one-dimensional array.
Örnekler
Bu örnek, işlevinin kullanımını gösterir Filter .This example demonstrates the use of the Filter function.
Dim testStrings(2) As String
testStrings(0) = "This"
testStrings(1) = "Is"
testStrings(2) = "It"
Dim subStrings() As String
' Returns ["This", "Is"].
subStrings = Filter(testStrings, "is", True, CompareMethod.Text)
' Returns ["This"].
subStrings = Filter(testStrings, "is", True, CompareMethod.Binary)
' Returns ["Is", "It"].
subStrings = Filter(testStrings, "is", False, CompareMethod.Binary)
Açıklamalar
Matchİçinde eşleşme bulunmazsa Source , Filter işlev boş bir dizi döndürür.If no matches of Match are found within Source, the Filter function returns an empty array. Bir hata oluşur Source Nothing veya, tek boyutlu bir dizi değildir veya olarak ayarlanır.An error occurs if Source is set to Nothing or is not a one-dimensional array.
İşlevin döndürdüğü dizi Filter yalnızca eşleşen öğe sayısını içerecek kadar öğe içeriyor.The array returned by the Filter function contains only enough elements to contain the number of matched items.
CompareBağımsız değişkeni aşağıdaki değerlere sahip olabilir.The Compare argument can have the following values.
| SabitConstant | DescriptionDescription |
|---|---|
CompareMethod.Binary |
İkili karşılaştırma yaparPerforms a binary comparison |
CompareMethod.Text |
Metinsel karşılaştırma yaparPerforms a textual comparison |
Ayrıca bkz.
- Replace(String, String, String, Int32, Int32, CompareMethod)
- ArgumentException
- Dize Düzenleme ÖzetiString Manipulation Summary
Şunlara uygulanır
Filter(String[], String, Boolean, CompareMethod)
Belirtilen filtre ölçütlerine göre bir dizinin alt kümesini içeren sıfır tabanlı bir dizi döndürür String .Returns a zero-based array containing a subset of a String array based on specified filter criteria.
public static string[]? Filter (string?[] Source, string? Match, bool Include = true, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
public static string[] Filter (string[] Source, string Match, bool Include = true, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
static member Filter : string[] * string * bool * Microsoft.VisualBasic.CompareMethod -> string[]
Public Function Filter (Source As String(), Match As String, Optional Include As Boolean = true, Optional Compare As CompareMethod = Microsoft.VisualBasic.CompareMethod.Binary) As String()
Parametreler
- Source
- String[]
Gereklidir.Required. Aranacak dizelerin tek boyutlu dizisi.One-dimensional array of strings to be searched.
- Match
- String
Gereklidir.Required. Aranacak dize.String to search for.
- Include
- Boolean
İsteğe bağlı.Optional. Boolean dahil edilen veya hariç tutulacak alt dizelerin döndürülüp döndürülmeyeceğini belirten değer Match .Boolean value indicating whether to return substrings that include or exclude Match. Includeİse True , Filter işlev alt dize olarak içeren dizinin alt kümesini döndürür Match .If Include is True, the Filter function returns the subset of the array that contains Match as a substring. Includeİse False , Filter işlev alt dize olarak içermeyen dizinin alt kümesini döndürür Match .If Include is False, the Filter function returns the subset of the array that does not contain Match as a substring.
- Compare
- CompareMethod
İsteğe bağlı.Optional. Kullanılacak dize karşılaştırma türünü gösteren sayısal değer.Numeric value indicating the kind of string comparison to use. Değerler için "Ayarlar"a bakın.See "Settings" for values.
Döndürülenler
- String[]
Belirtilen filtre ölçütlerine göre bir dizinin alt kümesini içeren sıfır tabanlı bir dizi String .A zero-based array containing a subset of a String array based on specified filter criteria.
Özel durumlar
Source , Nothing tek boyutlu bir dizi değil.Source is Nothing or is not a one-dimensional array.
Örnekler
Bu örnek, işlevinin kullanımını gösterir Filter .This example demonstrates the use of the Filter function.
Dim testStrings(2) As String
testStrings(0) = "This"
testStrings(1) = "Is"
testStrings(2) = "It"
Dim subStrings() As String
' Returns ["This", "Is"].
subStrings = Filter(testStrings, "is", True, CompareMethod.Text)
' Returns ["This"].
subStrings = Filter(testStrings, "is", True, CompareMethod.Binary)
' Returns ["Is", "It"].
subStrings = Filter(testStrings, "is", False, CompareMethod.Binary)
Açıklamalar
Matchİçinde eşleşme bulunmazsa Source , Filter işlev boş bir dizi döndürür.If no matches of Match are found within Source, the Filter function returns an empty array. Bir hata oluşur Source Nothing veya, tek boyutlu bir dizi değildir veya olarak ayarlanır.An error occurs if Source is set to Nothing or is not a one-dimensional array.
İşlevin döndürdüğü dizi Filter yalnızca eşleşen öğe sayısını içerecek kadar öğe içeriyor.The array returned by the Filter function contains only enough elements to contain the number of matched items.
CompareBağımsız değişkeni aşağıdaki değerlere sahip olabilir.The Compare argument can have the following values.
| SabitConstant | DescriptionDescription |
|---|---|
CompareMethod.Binary |
İkili karşılaştırma yaparPerforms a binary comparison |
CompareMethod.Text |
Metinsel karşılaştırma yaparPerforms a textual comparison |
Ayrıca bkz.
- Replace(String, String, String, Int32, Int32, CompareMethod)
- ArgumentException
- Dize Düzenleme ÖzetiString Manipulation Summary