VBScript - filterfunksie
❮ Voltooi VBScript-verwysingDie Filter-funksie gee 'n nul-gebaseerde skikking terug wat 'n subset van 'n string-skikking bevat gebaseer op 'n filterkriteria.
Let wel: As geen passings van die waardeparameter gevind word nie, sal die Filter-funksie 'n leë skikking terugstuur.
Let wel: As die parameter invoerstringe Nul is of NIE 'n eendimensionele skikking is nie, sal 'n fout voorkom.
Sintaksis
Filter(inputstrings,value[,include[,compare]])
Parameter | Description |
---|---|
inputstrings | Required. A one-dimensional array of strings to be searched |
value | Required. The string to search for |
include | Optional. A Boolean value that indicates whether to return the substrings that include or exclude value. True returns the subset of the array that contains value as a substring. False returns the subset of the array that does not contain value as a substring. Default is True. |
compare | Optional. Specifies the string comparison to use. Can have one of the following values:
|
Voorbeelde
Voorbeeld 1
Filter: items wat "S" bevat
<%
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S")
for each x in b
response.write(x & "<br />")
next
%>
Die afvoer van die kode hierbo sal wees:
Sunday
Saturday
Voorbeeld 2
Filter: items wat NIE "S" bevat nie (sluit in = Onwaar):
<%
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",False)
for each x in b
response.write(x & "<br />")
next
%>
Die afvoer van die kode hierbo sal wees:
Monday
Tuesday
Wednesday
Thursday
Friday
Voorbeeld 3
Filter: items wat "S" bevat, met 'n tekstuele vergelyking (vergelyk=1):
<%
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",True,1)
for each x in b
response.write(x & "<br />")
next
%>
Die afvoer van die kode hierbo sal wees:
Sunday
Tuesday
Wednesday
Thursday
Saturday
❮ Voltooi VBScript-verwysing