先定义一个字符串:

var aString = "you are beautiful,so beautiful,and i love you ver much";

拿到第一个逗号的位置:

var first = aString.indexOf(",");              //17

然后去拿第二个逗号的位置:

var second= aString.indexOf(",",first+1);   //30

截取两个逗号之间的内容:

var newString = aString.substring(first+1,second);

indexOf获取字符位置-LMLPHP

05-28 23:28