Javascript 仪器与索引
此ASP InStr函数是否等效于js indexOf函数: ASP:Javascript 仪器与索引,javascript,function,vbscript,indexof,instr,Javascript,Function,Vbscript,Indexof,Instr,此ASP InStr函数是否等效于js indexOf函数: ASP: 不,只有一例是相同的。若找不到值InStr返回0和indexOf return-1,但InStr还有许多其他值,请查看 差异 InStr函数返回一个字符串在另一个字符串中第一次出现的位置 InStr函数可以返回以下值: If string1 is "" - InStr returns 0 If string1 is Null - InStr returns Null If string2 is "" - InStr retu
不,只有一例是相同的。若找不到值InStr返回0和indexOf return-1,但InStr还有许多其他值,请查看 差异 InStr函数返回一个字符串在另一个字符串中第一次出现的位置 InStr函数可以返回以下值:
If string1 is "" - InStr returns 0
If string1 is Null - InStr returns Null
If string2 is "" - InStr returns start
If string2 is Null - InStr returns Null
If string2 is not found - InStr returns 0
If string2 is found within string1 - InStr returns the position at which match is found
If start > Len(string1) - InStr returns 0
而javascriptindexOf()
方法返回字符串中指定值第一次出现的位置
This method returns -1 if the value to search for never occurs.
如果您只想检查
var1
中是否存在var2
(带,
之前和
之后),那么它们是等效的,是的。问题解决了!
If string1 is "" - InStr returns 0
If string1 is Null - InStr returns Null
If string2 is "" - InStr returns start
If string2 is Null - InStr returns Null
If string2 is not found - InStr returns 0
If string2 is found within string1 - InStr returns the position at which match is found
If start > Len(string1) - InStr returns 0
This method returns -1 if the value to search for never occurs.