VBScript Mid 函数
❮ VBScript 参考大全
Mid 函数从字符串中返回指定数量的字符。
提示: 使用 Len 函数确定字符串中的字符数。
语法
Mid(string,start[,length])
参数 | 描述 |
---|---|
string | 必需。从中返回字符的字符串表达式 |
start | 必需。指定起始位置。如果大于字符串中的字符数,则返回空字符串 ("") |
length | 可选。要返回的字符数 |
示例
示例 1
从位置 1 开始返回 1 个字符
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1,1))
%>
上面代码的输出将是
T
显示示例 »
示例 2
从位置 1 开始返回 15 个字符
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1,15))
%>
上面代码的输出将是
This is a beaut
显示示例 »
示例 3
从位置 1 开始返回所有字符
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1))
%>
上面代码的输出将是
This is a beautiful day!
显示示例 »
示例 4
从位置 12 开始返回所有字符
<%
txt="This is a beautiful day!"
response.write(Mid(txt,12))
%>
上面代码的输出将是
eautiful day!
显示示例 »
❮ VBScript 参考大全