string-indexOf、substring、split
indexOf()
会搜索指定字符串出现的位置:
vars='hello,world';s.indexOf('world');//返回7s.indexOf('World');//没有找到指定的子串,返回-1
substring()
返回指定索引区间的子串:
vars='hello,world's.substring(0,5);//从索引0开始到5(不包括5),返回'hello's.substring(7);//从索引7开始到结束,返回'world'
splice:分割字符串 split(" ",3)
eg: how old are you?
结果:how、old、are、you? --------split(" ")
结果 how、old、are --------split(" ",3)
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。