android2.1中substr(str,0,X)和substr(str,1,X)返回的值是一样的,都是从第一字符开始截取X个字符。
而在android2.2中substr(str,0,X)是从第0个字符(相当于一个占位符)开始截取X个字符,substr(str,1,X)是从第1个字符开始截取X个字符。
例如: str="abcdefghijk"
在android2.1中:
substr(str,0,4)="abcd" substr(str,1,4)="abcd"
在android2.2中:
substr(str,0,4)="abc" substr(str,1,4)="abcd"
另外:
在android2.1中:(X为正整数)
substr(str,0,-X)=substr(str,1,-X)="abcdefghijk" substr(str,2,-X)="bcdefghijk"
substr(str,-2,X)=substr(str,-2,-X)="jk" substr(str,-1,X)=substr(str,-1,-X)="k"
在android2.2中:(X为正整数)
substr(str,0,-X)=substr(str,1,-X)="" substr(str,2,-X)="a" substr(str,3,-X)="b"
substr(str,-3,-100)="abcdefg" substr(str,-3,-2)="fg" substr(str,-3,0)=""
substr(str,-3,1)="h" substr(str,-3,2)="hi" substr(str,-3,100)="hijk"