Filter函数,该函数返回从零开始的数组,该数组包含基于特定过滤条件的字符串数组的子集。
语法
Filter(inputstrings,value[,include[,compare]])
- inputstrings,一个必需参数。此参数对应于要搜索的字符串数组。
- value,一个必需参数。此参数对应于针对inputstrings参数搜索的字符串。
- include,一个可选参数。这是一个布尔值,指示是否返回包含或排除的子字符串。
- compare,一个可选参数。该参数描述了要使用的字符串比较方法。
- 0 = vbBinaryCompare-执行二进制比较
- 1 = vbTextCompare-执行文本比较
例
<!DOCTYPE html> <html> <body> <script language = "vbscript" type = "text/vbscript"> a = array("Red","Blue","Yellow") b = Filter(a,"B") c = Filter(a,"e") d = Filter(a,"Y") For each x in b Document.write("The Filter result 1: " & x & "<br />") Next For each y in c Document.write("The Filter result 2: " & y & "<br />") Next For each z in d Document.write("The Filter result 3: " & z & "<br />") Next </script> </body> </html>
结果:
The Filter result 1: Blue The Filter result 2: Red The Filter result 2: Blue The Filter result 2: Yellow The Filter result 3: Yellow
作者:terry,如若转载,请注明出处:https://www.web176.com/vbscript/1195.html