首页 > 其他 > 详细

String 常用方法

时间:2018-03-23 11:15:38      阅读:173      评论:0      收藏:0      [点我收藏+]
// 不会改变原字符串
string.substring(startIndex, endIndex) —— 根据头尾位置返回一个字符串 string.substr(startIndex, length) —— 根据头位置与长度返回一个字符串 string.indexOf(
"s",index) —— 从字符串头部开始,返回某字符在字符串中的索引,第二个参数指定从哪个索引开始检索 string.lastIndexOf("s",index) —— 从字符串尾部开始,返回某字符在字符串中的索引,第二个参数指定从哪个索引开始检索 string.match(pattern) —— 字符串根据正则返回数组 string.search(pattern) —— 字符串根据正则返回第一个匹配项的索引 string.replace(oldstring.newstring) —— 只替换第一个符合的,如果替换全部则第一个参数需要使用正则

 

String 常用方法

原文:https://www.cnblogs.com/founderswitch/p/8628811.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!