java 字符串的截取
string str="123abc456";
int i=3;
- 取字符串的前i个字符
str=str.Substring(0,i);
// or
str=str.Remove(i,str.Length-i);
- 去掉字符串的前i个字符:
str=str.Remove(0,i);
// or
str=str.Substring(i);
- 从右边开始取i个字符:
str=str.Substring(str.Length-i);
// or
str=str.Remove(0,str.Length-i);
4 从右边开始去掉i个字符:
str=str.Substring(0,str.Length-i);
// or
str=str.Remove(str.Length-i,i);
- 如果字符串中有"abc"则替换成"ABC"
str=str.Replace("abc","ABC");
1 条评论
你的文章内容非常卖力,让人点赞。 http://www.55baobei.com/SbFcA4X4k2.html