VBScript Filter Function
Complete VBScript Reference
The Filter function returns a zero-based array that contains a subset of a
string array based on a filter criteria.
Note: If no matches of the value parameter are found, the Filter
function will return an empty array.
Note: If the parameter inputstrings is Null or is NOT a
one-dimensional array, an error will occur.
Syntax
|
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:
- 0 = vbBinaryCompare - Perform a binary comparison
- 1 = vbTextCompare - Perform a textual comparison
|
Examples
Example 1
Filter: items that contains "S"
<script type="text/vbscript">
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S")
for each x in b
document.write(x & "<br />")
next
</script>
|
The output of the code above will be:
Try it yourself »
|
Example 2
Filter: items that does NOT contain "S" (include=False):
<script type="text/vbscript">
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",False)
for each x in b
document.write(x & "<br />")
next
</script>
|
The output of the code above will be:
Monday
Tuesday
Wednesday
Thursday
Friday
|
Try it yourself »
|
Example 3
Filter: items that contains "S", with a textual comparison (compare=1):
<script type="text/vbscript">
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",True,1)
for each x in b
document.write(x & "<br />")
next
</script>
|
The output of the code above will be:
Sunday
Tuesday
Wednesday
Thursday
Saturday |
Try it yourself »
|
Complete VBScript Reference
Stylus Studio® 2010 XML Enterprise Suite raises the bar for productivity in XML development tools.
Millions of XML developers and data integration specialists turn to Stylus Studio's comprehensive and intuitive
XML toolset to tackle today's advanced XML data transformation and aggregation challenges.
|
- XML Pipeline Editor, Debugger and Code Generator
- DataDirect XML Converters
- XQuery Mapper, Editor, Debugger, and Profiler
- XSLT Mapper, Editor, Debugger, Designer, and Profiler
- Java and C# for .Net Code Generation
- XML Schema Designer With Documentation Generator
- XML Editor With Full XPath Integration
Download a free trial now
|
|