VBScript InStrRev º¯Êý

¶¨ÒåºÍÓ÷¨

InStrRev º¯Êý¿É·µ»ØÒ»¸ö×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖÐÊ״γöÏÖµÄλÖá£ËÑË÷´Ó×Ö·û´®µÄÄ©¶Ë¿ªÊ¼£¬µ«ÊÇ·µ»ØµÄλÖÃÊÇ´Ó×Ö·û´®µÄÆðµã¿ªÊ¼¼ÆÊýµÄ¡£

InStrRev º¯Êý¿É·µ»ØÏÂÃæµÄÖµ£º

  • Èç¹û string1 Ϊ ""£¨Á㳤¶È£© - InStr ·µ»Ø 0
  • Èç¹û string1 Ϊ Null - InStr ·µ»Ø Null
  • Èç¹û string2 Ϊ "" - InStr ·µ»Ø start
  • Èç¹û string2 Ϊ Null - InStr ·µ»Ø Null
  • Èç¹û string2 ûÓÐÕÒµ½ - InStr ·µ»Ø 0
  • Èç¹ûÔÚ string1 ÖÐÕÒµ½ string2£¬InStr ·µ»ØÕÒµ½Æ¥Åä×Ö·û´®µÄλÖá£
  • Èç¹û start > Len(string1) - InStr ·µ»Ø 0

Ìáʾ£ºÇë²ÎÔÄ InStr º¯Êý¡£

Óï·¨

InStrRev(string1,string2[,start[,compare]])
²ÎÊý ÃèÊö
start ¿ÉÑ¡µÄ¡£¹æ¶¨Ã¿´ÎËÑË÷µÄÆðʼλÖá£Ä¬ÈÏÊÇËÑË÷ÆðʼλÖÃÊǵÚÒ»¸ö×Ö·û¡£Èç¹ûÒѹ涨 compare ²ÎÊý£¬Ôò±ØÐëÓд˲ÎÊý¡£
string1 ±ØÐèµÄ¡£ÐèÒª±»ËÑË÷µÄ×Ö·û´®¡£
string2 ±ØÐèµÄ¡£ÐèËÑË÷µÄ×Ö·û´®¡£
compare

±ØÐèµÄ¡£¹æ¶¨ÒªÊ¹ÓõÄ×Ö·û´®±È½ÏÀàÐÍ¡£Ä¬ÈÏÊÇ 0 ¡£¿É²ÉÓÃÏÂÁÐÖµ£º

  • 0 = vbBinaryCompare - Ö´Ðжþ½øÖƱȽϡ£
  • 1 = vbTextCompare - Ö´ÐÐÎı¾±È½Ï¡£

ʵÀý

Àý×Ó 1

dim txt,pos
txt="This is a beautiful day!"
pos=InStrRev(txt,"his")
document.write(pos)

Êä³ö£º

2

Àý×Ó 2

dim txt,pos
txt="This is a beautiful day!"
'textual comparison
pos=InStrRev(txt,"B",-1,1)
document.write(pos)

Êä³ö£º

11

Àý×Ó 3

dim txt,pos
txt="This is a beautiful day!"
'binary comparison
pos=InStrRev(txt,"T")
document.write(pos)

Êä³ö£º

1

Àý×Ó 4

dim txt,pos
txt="This is a beautiful day!"
'binary comparison
pos=InStrRev(txt,"t")
document.write(pos)

Êä³ö£º

15
VUE