Strings.Filter Metodo
Definizione
Restituisce una matrice con indice in base zero che contiene un sottoinsieme di una matrice String
definito in base ai criteri di filtro specificati.Returns a zero-based array containing a subset of a String
array based on specified filter criteria.
Overload
Filter(Object[], String, Boolean, CompareMethod) |
Restituisce una matrice con indice in base zero che contiene un sottoinsieme di una matrice |
Filter(String[], String, Boolean, CompareMethod) |
Restituisce una matrice con indice in base zero che contiene un sottoinsieme di una matrice |
Filter(Object[], String, Boolean, CompareMethod)
Restituisce una matrice con indice in base zero che contiene un sottoinsieme di una matrice String
definito in base ai criteri di filtro specificati.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);
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()
Parametri
- Source
- Object[]
Obbligatorio.Required. Matrice unidimensionale delle stringhe da cercare.One-dimensional array of strings to be searched.
- Match
- String
Obbligatorio.Required. Stringa da cercare.String to search for.
- Include
- Boolean
Opzionale.Optional. Valore Boolean
che indica se restituire sottostringhe che includono o escludono il parametro Match
.Boolean
value indicating whether to return substrings that include or exclude Match
. Se Include
è True
, la funzione Filter
restituisce il sottoinsieme della matrice che contiene Match
in formato di sottostringa.If Include
is True
, the Filter
function returns the subset of the array that contains Match
as a substring. Se Include
è False
, la funzione Filter
restituisce il sottoinsieme della matrice che non contiene Match
in formato di sottostringa.If Include
is False
, the Filter
function returns the subset of the array that does not contain Match
as a substring.
- Compare
- CompareMethod
Facoltativo.Optional. Valore numerico che indica il tipo di confronto da utilizzare per le stringhe.Numeric value indicating the kind of string comparison to use. Per un elenco dei valori possibili, vedere "Impostazioni".See "Settings" for values.
Restituisce
Matrice in base zero contenente un subset di una matrice String
sulla base di criteri di filtro specificati.A zero-based array containing a subset of a String
array based on specified filter criteria.
Eccezioni
Source
è Nothing
oppure non è una matrice unidimensionale.Source
is Nothing
or is not a one-dimensional array.
Esempi
Questo esempio illustra l'uso della funzione 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)
Commenti
Se non vengono trovate corrispondenze di Match
entro Source
, la funzione Filter
restituisce una matrice vuota.If no matches of Match
are found within Source
, the Filter
function returns an empty array. Si verifica un errore se Source
è impostato su Nothing
oppure non è una matrice unidimensionale.An error occurs if Source
is set to Nothing
or is not a one-dimensional array.
La matrice restituita dalla funzione Filter
contiene solo elementi sufficienti per contenere il numero di elementi corrispondenti.The array returned by the Filter
function contains only enough elements to contain the number of matched items.
L'argomento Compare
può includere i valori seguenti.The Compare
argument can have the following values.
CostanteConstant | DescriptionDescription |
---|---|
CostanteConstant | DescriptionDescription |
CompareMethod.Binary |
Esegue un confronto binarioPerforms a binary comparison |
CompareMethod.Text |
Esegue un confronto testualePerforms a textual comparison |
Vedi anche
Filter(String[], String, Boolean, CompareMethod)
Restituisce una matrice con indice in base zero che contiene un sottoinsieme di una matrice String
definito in base ai criteri di filtro specificati.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);
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()
Parametri
- Source
- String[]
Obbligatorio.Required. Matrice unidimensionale delle stringhe da cercare.One-dimensional array of strings to be searched.
- Match
- String
Obbligatorio.Required. Stringa da cercare.String to search for.
- Include
- Boolean
facoltativo.Optional. Valore Boolean
che indica se restituire sottostringhe che includono o escludono il parametro Match
.Boolean
value indicating whether to return substrings that include or exclude Match
. Se Include
è True
, la funzione Filter
restituisce il sottoinsieme della matrice che contiene Match
in formato di sottostringa.If Include
is True
, the Filter
function returns the subset of the array that contains Match
as a substring. Se Include
è False
, la funzione Filter
restituisce il sottoinsieme della matrice che non contiene Match
in formato di sottostringa.If Include
is False
, the Filter
function returns the subset of the array that does not contain Match
as a substring.
- Compare
- CompareMethod
Facoltativo.Optional. Valore numerico che indica il tipo di confronto da utilizzare per le stringhe.Numeric value indicating the kind of string comparison to use. Per un elenco dei valori possibili, vedere "Impostazioni".See "Settings" for values.
Restituisce
Matrice in base zero contenente un subset di una matrice String
sulla base di criteri di filtro specificati.A zero-based array containing a subset of a String
array based on specified filter criteria.
Eccezioni
Source
è Nothing
oppure non è una matrice unidimensionale.Source
is Nothing
or is not a one-dimensional array.
Esempi
Questo esempio illustra l'uso della funzione 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)
Commenti
Se non vengono trovate corrispondenze di Match
entro Source
, la funzione Filter
restituisce una matrice vuota.If no matches of Match
are found within Source
, the Filter
function returns an empty array. Si verifica un errore se Source
è impostato su Nothing
oppure non è una matrice unidimensionale.An error occurs if Source
is set to Nothing
or is not a one-dimensional array.
La matrice restituita dalla funzione Filter
contiene solo elementi sufficienti per contenere il numero di elementi corrispondenti.The array returned by the Filter
function contains only enough elements to contain the number of matched items.
L'argomento Compare
può includere i valori seguenti.The Compare
argument can have the following values.
CostanteConstant | DescriptionDescription |
---|---|
CompareMethod.Binary |
Esegue un confronto binarioPerforms a binary comparison |
CompareMethod.Text |
Esegue un confronto testualePerforms a textual comparison |