VBScript InStrRev 函数
Pangungusap at paggamit
Maaaring ibabalik ng InStrRev 函数 ang posisyon ng unang pagkakaroon ng isang string sa ibang string. Ang paghahanap ay nagsimula mula sa dulo ng string, ngunit ang ibabalik na posisyon ay mula sa simula ng string.
Maaaring ibabalik ng InStrRev 函数 ang mga sumusunod na halaga:
- Kung ang string1 ay "" (walang haba) - ibabalik ng InStr 0
- Kung ang string1 ay Null - ibabalik ng InStr Null
- Kung ang string2 ay "" - ibabalik ng InStr ang start
- Kung ang string2 ay Null - ibabalik ng InStr Null
- Kung hindi nasumpungan ang string2 - ibabalik ng InStr 0
- Kung nasumpungan ang string2 sa string1, ibabalik ng InStr ang posisyon ng nakuha na katumbas na string.
- Kung ang start > Len(string1) - InStr ay ibabalik 0
Paalaala:Mga paliwanag InStr 函数。
Syntax
InStrRev(string1,string2[,start[,compare]])
Parameter | Description |
---|---|
start | Optional. Specifies the starting position for each search. The default is the first character of the search. If the compare parameter is specified, this parameter must also be specified. |
string1 | Required. The string to be searched for. |
string2 | Required. The string to be searched. |
compare |
Required. Specifies the type of string comparison to use. The default is 0. The following values can be used:
|
Instance
Example 1
dim txt,pos txt="This is a beautiful day!" pos=InStrRev(txt,"his") document.write(pos)
Output:
2
Example 2
dim txt,pos txt="This is a beautiful day!" 'textual comparison' pos=InStrRev(txt,"B",-1,1) document.write(pos)
Output:
11
Example 3
dim txt,pos txt="This is a beautiful day!" 'binary comparison' pos=InStrRev(txt,"T") document.write(pos)
Output:
1
Example 4
dim txt,pos txt="This is a beautiful day!" 'binary comparison' pos=InStrRev(txt,"t") document.write(pos)
Output:
15