VBScript Left 函數(shù)
定義和用法
Left 函數(shù)可從字符串的左側(cè)返回指定數(shù)目的字符。
提示:請(qǐng)使用 Len 函數(shù)來(lái)確定字符串中的字符數(shù)目。
提示:請(qǐng)參閱 Right 函數(shù)。
語(yǔ)法
Left(string,length)
參數(shù) | 描述 |
---|---|
string | 必需的。從其中返回字符的字符串。 |
length | 必需的。規(guī)定需返回多少字符。如果設(shè)置為 0,則返回空字符串("")。如果設(shè)置為大于或等于字符串的長(zhǎng)度,則返回整個(gè)字符串。 |
實(shí)例
例子 1
dim txt txt="This is a beautiful day!" document.write(Left(txt,11))
輸出:
This is a b
例子 2
dim txt txt="This is a beautiful day!" document.write(Left(txt,100))
輸出:
This is a beautiful day!
例子 3
dim txt,x txt="This is a beautiful day!" x=Len(txt) document.write(Left(txt,x))
輸出:
This is a beautiful day!