VBScript:Filter函数

目录

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

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2020年12月8日 上午11:11
下一篇 2020年12月8日 上午11:13

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注