日期:2014-05-18 浏览次数:20764 次
public static ArrayList getanythings(string body, string fs,string ends)
{
ArrayList imagepath=new ArrayList();//数组
int intf = body.IndexOf(fs);//前标索引
int inte = body.IndexOf(ends);//后标索引
bool inbody;//开关,段落是否包含1对标记
if (intf < inte) { inbody = true; }
else{inbody=false;}
while(inbody==true)//开
{
//返回[image]xxxxx[/image]
string temp = body.Substring(body.IndexOf(fs),body.IndexOf(ends)+ends.Length-body.IndexOf(fs));
//去掉[image][/image]返回xxxxx
string fpath = (temp.Substring(fs.Length, temp.Length - fs.Length - ends.Length));
//标记在文本首部先add " "
if (intf == 0) { imagepath.Add(" "); body = body.Remove(body.IndexOf(fs),temp.Length); }
else {
if(fpath.IndexOf(fs)==-1) //判断标记内是否有嵌套的标记
{
body= body.Remove(body.IndexOf(fs),temp.Length); //有的话删除作废标记
}
else
{
imagepath.Add(us.MyReplace(body.Substring(0, intf)));//添加文本到数组 us.MyReplace 是自己的处理string的方法
imagepath.Add(fpath);//添加标记内容xxxxx
body = body.Remove(body.IndexOf(fs), temp.Length);//删除已添加的标记
}
}
}
imagepath.Add(body);//添加最后条文本
return imagepath;//返回添加后最终数组
}