VBScript InStrRev 함수


❮ 완전한 VBScript 참조

InStrRev 함수는 다른 문자열 내에서 한 문자열이 처음 나타나는 위치를 반환합니다. 검색은 문자열 끝에서 시작되지만 반환된 위치는 문자열 시작부터 계산됩니다.

InStrRev 함수는 다음 값을 반환할 수 있습니다.

  • string1이 ""인 경우 - InStrRev는 0을 반환합니다.
  • string1이 Null인 경우 - InStrRev는 Null을 반환합니다.
  • string2가 ""인 경우 - InStrRev는 시작을 반환합니다.
  • string2가 Null인 경우 - InStrRev는 Null을 반환합니다.
  • string2를 찾을 수 없는 경우 - InStrRev는 0을 반환합니다.
  • string2가 string1 내에 있는 경우 - InStrRev는 일치 항목이 발견된 위치를 반환합니다.
  • 시작 > Len(string1)인 경우 - InStrRev는 0을 반환합니다.

팁: InStr 함수도 살펴보세요.

통사론

InStrRev(string1,string2[,start[,compare]])

Parameter Description
string1 Required. The string to be searched
string2 Required. The string expression to search for
start Optional. Specifies the starting position for each search. The search begins at the last character position by default (-1)
compare Optional. Specifies the string comparison to use. Default is 0

Can have one of the following values:

  • 0 = vbBinaryCompare - Perform a binary comparison
  • 1 = vbTextCompare - Perform a textual comparison

실시예 1

<%

txt="This is a beautiful day!"
response.write(InStrRev(txt,"beautiful"))

%>

위 코드의 출력은 다음과 같습니다.

11

실시예 2

다른 시작 위치를 사용하여 문자 "i" 찾기:

<%

txt="This is a beautiful day!"
response.write(InStrRev(txt,"i",-1) & "<br />")
response.write(InStrRev(txt,"i",7) & "<br />")

%>

위 코드의 출력은 다음과 같습니다.

16
6

실시예 3

텍스트 및 이진 비교로 문자 "T" 찾기:

<%

txt="This is a beautiful day!"
response.write(InStrRev(txt,"T",-1,1) & "<br />")
response.write(InStrRev(txt,"T",-1,0) & "<br />")

%>

위 코드의 출력은 다음과 같습니다.

15
1

❮ 완전한 VBScript 참조