码迷,mamicode.com
首页 > 其他好文 > 详细

关于indexof和substring经常记不住的点

时间:2017-06-25 12:46:18      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:last   bst   host   substr   local   str   字符   substring   index   

indexof 找到的字符位置是 字符串从0位开始算起的。

lastIndexOf也一样,http://localhost:8080/aaa,的lastIndexOf("/")是21位。

substring(0,a)截取的是,从0位开始算起的,直到第(a-1)位字符,不包含a位字符,例如:

var str = "http://localhost:8080/aaa";

substring(0,str.lastIndexOf("/"))得到的是"http://localhost:8080"。

关于indexof和substring经常记不住的点

标签:last   bst   host   substr   local   str   字符   substring   index   

原文地址:http://www.cnblogs.com/samwang88/p/7076455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!