Filter Function

Tips >>ASP Functions

WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE

The Filter function returns a zero-based array that contains a subset of a string array based on a filter criteria. You can create a zero-based string array by using the Split function. The Join function is used to reassemble the string after applying the Filter function.


There are Two Mandatory Arguments :-

  • String :- The String argument is the name of a zero-based string array.

  • Sub String :- The Sub String argument is the pattern of one or more characters that are searched for in the array.

Note :- If no matches of the value parameter are found, the Filter function will return an empty array.

Note :- If the parameter input strings is Null or is NOT a one-dimensional array, an error will occur.

The Syntax of Filter function is :-

Filter(inputstrings,value[,include[,compare]])

The Filter function syntax has these parts :-

Part Description
InputStrings Required. One-dimensional array of strings to be searched.
Value Required. String to search for.
Include Optional. Boolean value indicating whether to return substrings that include or exclude Value. If Include is True, Filter returns the subset of the array that contains Value as a substring. If Include is False, Filter returns the subset of the array that does not contain Value as a substring.
Compare Optional. Numeric value indicating the kind of string comparison to use. See Settings section for values.


The Compare argument can have the following values :-

Constant Value Description
vbBinaryCompare 0 Perform a binary comparison.
vbTextCompare 1 Perform a textual comparison.
vbDatabaseCompare 2 Perform a comparison based on information contained in the database where the comparison is to be performed.

Example#1 :-

Code :-
dim a(5),b
a(0)="Saturday"
a(1)="Sunday"
a(2)="Monday"
a(3)="Tuesday"
a(4)="Wednesday"
b=Filter(a,"n")
document.write(b(0) & "<br />")
document.write(b(1) & "<br />")
document.write(b(2))
Output :-
Sunday, Monday, Wednesday

Example#2 :-

Code :-
dim a(5),b
a(0)="Saturday"
a(1)="Sunday"
a(2)="Monday"
a(3)="Tuesday"
a(4)="Wednesday"
b=Filter(a,"n",false)
document.write(b(0) & "<br />")
document.write(b(1) & "<br />")
document.write(b(2))
Output :-
Saturday, Tuesday

 
 

Filter Function

Tips >>ASP Functions

The Filter function returns a zero-based array that contains a subset of a string array based on a filter criteria. You can create a zero-based string array by using the Split function. The Join function is used to reassemble the string after applying the Filter function.


There are Two Mandatory Arguments :-

  • String :- The String argument is the name of a zero-based string array.

  • Sub String :- The Sub String argument is the pattern of one or more characters that are searched for in the array.

Note :- If no matches of the value parameter are found, the Filter function will return an empty array.

Note :- If the parameter input strings is Null or is NOT a one-dimensional array, an error will occur.

The Syntax of Filter function is :-

Filter(inputstrings,value[,include[,compare]])

The Filter function syntax has these parts :-

PartDescription
InputStringsRequired. One-dimensional array of strings to be searched.
ValueRequired. String to search for.
IncludeOptional. Boolean value indicating whether to return substrings that include or exclude Value. If Include is True, Filter returns the subset of the array that contains Value as a substring. If Include is False, Filter returns the subset of the array that does not contain Value as a substring.
CompareOptional. Numeric value indicating the kind of string comparison to use. See Settings section for values.


The Compare argument can have the following values :-

ConstantValueDescription
vbBinaryCompare0 Perform a binary comparison.
vbTextCompare 1Perform a textual comparison.
vbDatabaseCompare2Perform a comparison based on information contained in the database where the comparison is to be performed.

Example#1 :-

Code :-
dim a(5),b
a(0)="Saturday"
a(1)="Sunday"
a(2)="Monday"
a(3)="Tuesday"
a(4)="Wednesday"
b=Filter(a,"n")
document.write(b(0) & "<br />")
document.write(b(1) & "<br />")
document.write(b(2))
Output :-
Sunday, Monday, Wednesday

Example#2 :-

Code :-
dim a(5),b
a(0)="Saturday"
a(1)="Sunday"
a(2)="Monday"
a(3)="Tuesday"
a(4)="Wednesday"
b=Filter(a,"n",false)
document.write(b(0) & "<br />")
document.write(b(1) & "<br />")
document.write(b(2))
Output :-
Saturday, Tuesday