Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

VBScript Split 函数


❮ VBScript 全面参考

Split 函数返回一个从零开始的一维数组,其中包含指定数量的子字符串。

语法

Split(expression[,delimiter[,count[,compare]]])

参数 描述
expression 必需。包含子字符串和分隔符的字符串表达式
delimiter 可选。用于标识子字符串限制的字符串字符。默认值为空格字符
count 可选。要返回的子字符串数量。-1 表示返回所有子字符串
compare 可选。指定要使用的字符串比较。

可以具有以下值之一

  • 0 = vbBinaryCompare - 执行二进制比较
  • 1 = vbTextCompare - 执行文本比较

示例

示例 1

<%

a=Split("W3Schools is my favourite website")
for each x in a
    response.write(x & "<br />")
next

%>

以上代码的输出将是

W3Schools
is
my
favourite
website
显示示例 »

示例 2

使用分隔符参数分割文本

<%

a=Split("Brown cow, White horse, Yellow chicken",",")
for each x in a
    response.write(x & "<br />")
next

%>

以上代码的输出将是

Brown cow
White horse
Yellow chicken
显示示例 »

示例 3

使用分隔符参数和计数参数分割文本

<%

a=Split("W3Schools is my favourite website"," ",2)
for each x in a
    response.write(x & "<br />")
next

%>

以上代码的输出将是

W3Schools
is my favourite website
显示示例 »

示例 4

使用带有文本比较的分隔符参数分割文本

<%

a=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,1)
for each x in a
    response.write(x & "<br />")
next

%>

以上代码的输出将是

Sun
Mon
Tues
WEDNES
Thurs
Fri
Satur
显示示例 »

示例 5

使用带有二进制比较的分隔符参数分割文本

<%

a=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,0)
for each x in a
    response.write(x & "<br />")
next

%>

以上代码的输出将是

Sun
Mon
Tues
WEDNESDAYThurs
Fri
Satur
显示示例 »

❮ VBScript 全面参考
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.