var box = "this is javascript"; for (var i = -1, arr = []; (i = box.indexOf("s", i + 1)) > -1; arr.push(i)); alert(arr); 其原理还可以这样理解: var str ="this is javascript" var resault ={index:"",count:0}; while ( true ){…
[1编写函数]CREATE FUNCTION IndexOf(@str VARCHAR(500),@value VARCHAR(50),@posIndex INT)RETURNS int AS BEGIN DECLARE @pos int=0 --记录位置 DECLARE @i INT =0 --记录查找的次数 WHILE(@i<@posindex) BEGIN SET @i=@i+1 set @pos=CHARINDEX(@value,@str,@pos+1) IF(@pos=0) RETUR…