最佳答案
                                        
                                                                        
                                我有一个需要解析的大字符串,我需要找到 extract"(me,i-have lots. of]punctuation的所有实例,并将每个实例的索引存储到一个列表中。
假设这段字符串位于较大字符串的开头和中间,这两个字符串都会被找到,它们的索引将被添加到 List中。List将包含 0和另一个索引,不管它是什么。
我一直在玩,string.IndexOf做 差不多什么我在寻找,我已经写了一些代码-但它不工作,我一直无法找出究竟是什么错误:
List<int> inst = new List<int>();
int index = 0;
while (index < source.LastIndexOf("extract\"(me,i-have lots. of]punctuation", 0) + 39)
{
int src = source.IndexOf("extract\"(me,i-have lots. of]punctuation", index);
inst.Add(src);
index = src + 40;
}
有更好的主意吗?