首页 > 其他 > 详细

substring的用法

时间:2014-03-29 11:01:50      阅读:631      评论:0      收藏:0      [点我收藏+]

1.java和javascript中的用法相似

java中substring的用法:

str=str.substring(int beginIndex);截取掉str从首字母起长度为beginIndex的字符串,将剩余字符串赋值给str;

str=str.substring(int beginIndex,int endIndex);截取str中从beginIndex开始至endIndex结束时的字符串,并将其赋str;

javascript中substring的用法:

stringObject.substring(start,stop)

返回值:
一个新的字符串,该字符串值包含 stringObject 的一个子字符串,其内容是从 start 处到 stop-1 处的所有字符,其长度为 stop start

   说明:substring() 方法返回的子串包括 start 处的字符,但不包括 stop 处的字符。

     如果参数 start  stop 相等,那么该方法返回的就是一个空串(即长度为 0 的字符串)。如 果 start  stop 大,那么该方法在提取子串之前会先交换这两个参数。

提示和注释:重要事项: slice()  substr() 方法不同的是,substring() 不接受负的参数。

2.c#中独特的用法

String.Substring 方法 (Int32, Int32)

参数

startIndex
类型:System.Int32
此实例中子字符串的起始字符位置(从零开始)。
length
类型:System.Int32
子字符串中的字符数。

返回值

类型:System.String
length that begins at startIndex in this instance, or Empty if startIndex is equal to the length of this instance and length is zero.‘ data-guid="f5433c51c981d11e0916b93c320953d1">与此实例中在 startIndex 处开头、长度为 length 的子字符串等效的一个字符串,如果 startIndex 等于此实例的长度且 length 为零,则为 Empty

substring的用法,布布扣,bubuko.com

substring的用法

原文:http://www.cnblogs.com/jinTaylor/p/3630931.html

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