VBScript Mid 함수
定义和用法
Mid 함수可从字符串中返回指定数目的字符。
提示:请使用 Len 函数来确定字符串中的字符数目。
语法
Mid(string,start[,length])
参数 | 描述 |
---|---|
string | 必需的。从其中返回字符的字符串表达式。如果字符串包含 Null,则返回 Null。 |
start | 必需的。规定起始位置。如果设置为大于字符串中的字符数目,则返回空字符串("")。 |
length | 선택 사항입니다. 반환할 문자 수를 지정합니다. 생략하거나 length가 문자 수를 초과하면(시작 위치 포함), 문자열에서 시작 위치부터 문자열의 끝까지의 모든 문자를 반환합니다. |
예제
예제 1
dim txt txt="This is a beautiful day!" document.write(Mid(txt,1,1))
출력:
T
예제 2
dim txt txt="This is a beautiful day!" document.write(Mid(txt,1,11))
출력:
This is a b
예제 3
dim txt txt="This is a beautiful day!" document.write(Mid(txt,1))
출력:
This is a beautiful day!
예제 4
dim txt txt="This is a beautiful day!" document.write(Mid(txt,10))
출력:
아름다운 하루!