VBScript 중간 기능


❮ 완전한 VBScript 참조

Mid 함수는 문자열에서 지정된 수의 문자를 반환합니다.

팁: Len 함수를 사용하여 문자열의 문자 수를 확인합니다.

통사론

Mid(string,start[,length])

Parameter Description
string Required. The string expression from which characters are returned
start Required. Specifies the starting position. If set to greater than the number of characters in string, it returns an empty string ("")
length Optional. The number of characters to return

실시예 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 참조