VBScript:Split函数

目录

拆分函数返回一个数组,该数组包含基于定界符拆分的特定数量的值。

语法

Split(expression[,delimiter[,count[,compare]]]) 
  • expression,一个必需参数。字符串表达式,可以包含带有定界符的字符串。
  • delimiter,一个可选参数。参数,用于基于定界符转换为数组。
  • count,一个可选参数。要返回的子字符串数,如果指定为-1,则返回所有子字符串。
  • compare,一个可选参数。此参数指定要使用的比较方法。
    • 0 = vbBinaryCompare-执行二进制比较
    • 1 = vbTextCompare-执行文本比较

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         ' Splitting based on delimiter comma '$'
         a = Split("Red $ Blue $ Yellow","$")
         b = ubound(a)
         
         For i = 0 to b
            document.write("The value of array in " & i & " is :"  & a(i)& "<br />")
         Next

      </script>
   </body>
</html>

当以上代码另存为.HTML并在Internet Explorer中执行时,它会产生以下结果:

The value of array in 0 is :Red 
The value of array in 1 is : Blue 
The value of array in 2 is : Yellow

作者:terry,如若转载,请注明出处:https://www.web176.com/vbscript/1191.html

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

相关推荐

发表回复

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