分割/截取字符串
来源:互联网 发布:解压缩zip linux 编辑:程序博客网 时间:2024/06/05 16:05
截取字最后一个字符
1.string s2=s1.Remove(s1.LastIndexOf(","));
2.id = id.Substring(0, id.LastIndexOf(","));按","分割字符串
1.string[] c_id = id.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
2.定义成方法返回List<string>
/// <param name="o_str">需分组字符</param>
/// <param name="sepeater">分割符 eg:"|"</param>
public static List<string> GetSubStringList(string o_str, char sepeater)
{List<string> list = new List<string>();
string[] ss = o_str.Split(sepeater);
foreach (string s in ss)
{
if (!string.IsNullOrEmpty(s) && s != sepeater.ToString())
{
list.Add(s);
}
}
return list;
}
3. 两个分割用法
if (model != null)
{
string[] list = model.str.Split('|');
if (model.str.IndexOf('|') < 0)
{
list = model.str.Split(' ');
}
foreach (string s in model.str.Split(' '))
{
sb.Append(html.Replace("$lis", "" + s));
}
return sb.ToString();
}
0 0
- 分割/截取字符串
- QString 截取分割字符串
- C#字符串分割、截取
- QString截取分割字符串
- C#字符串截取,字符串分割
- oracle 分割字符串 截取字符串
- oracle 分割字符串 截取字符串
- C#字符串测试---------字符串截取,字符串分割
- c# 截取字符串和分割字符串
- shell下分割字符串以及截取字符串
- Swift 分割字符串与截取字符串
- 字符串的分割和字串截取
- 【好程序员特训营】Java字符串截取分割
- 几种字符串截取、分割方法
- php字符串的长度计算、截取、分割
- iOS字符串的截取、匹配、分割
- 2、Oracle PL/SQL字符串分割截取
- shell 脚本字符串 分割或截取
- ubuntu 13.10挂载windows共享目录
- SNMP常用OID查询
- SQL收缩日志
- oppo find 7特色功能
- org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehau
- 分割/截取字符串
- 分布式基础——RPC通信
- 字符串匹配之BM和KMP算法
- EL表达式
- linux 共享内存与nginx共享内存
- eclipse常用快捷键
- Linux下cron的使用
- 诺基亚新专利
- Android自定义属性,format详解