All Functions
Replace Function
FUNCTION: Filter( )
Implemented in version 1.0
Filter
(String, Substring,
Include,Compare
)
The
Filter
function searches the elements of a zero-based array, to match a pattern of one or more characters, and creates a new array, either with or without the elements containing the matched pattern.
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.
Substring
The
Substring
argument is the pattern of one or more characters that are searched for in the array.
Code:
<% myarray = Split("How now purple cow?") %>
<% myfilterarray = Filter(myarray, "ow") %>
<% =Join(myfilterarray) %>
Output:
How now cow?
There are two optional arguments.
Include
The optional
Include
argument must only be
True
or
False
. If
True
, the returned array will only consist of the values that contain the search pattern. If
False
, the returned array will only consist of the values that do not contain the search pattern.
Code:
<% myarray = Split("How now purple cow?") %>
<% myfilterarray = Filter(myarray, "ow", True) %>
<% =Join(myfilterarray) %>
Output:
How now cow?
Code:
<% myarray = Split("How now purple cow?") %>
<% myfilterarray = Filter(myarray, "ow", False) %>
<% =Join(myfilterarray) %>
Output:
purple
Compare
The optional
Compare
argument must only use either the constant or value of the COMPARISON CONSTANTS.
CONSTANT
VALUE
DESCRIPTION
VBBinaryCompare
0
Binary comparison
VBTextCompare
1
Text Comparison
VBDataBaseCompare
2
Compare information inside database
In the example, by using VBBinaryCompare, or 0, for the
Compare
argument, all upper/lower case differences are obeyed in the search.
Code:
<% myarray = Split("How now purple cow?") %>
<% myfilterarray = Filter(myarray, "OW", True, 0) %>
<% =Join(myfilterarray) %>
Output:
(No output, because no match)
In the example, by using VBTextCompare, or 1, for the
Compare
argument, all upper/lower case differences are ignored in the search.
Code:
<% myarray = Split("How now purple cow?") %>
<% myfilterarray = Filter(myarray, "OW", True, VBTextCompare) %>
<% =Join(myfilterarray) %>
Output:
How now cow?
Copyright 1999-2004 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information