110,549
社区成员
发帖
与我相关
我的任务
分享
List<string> result = new List<string>();
string a = "string string ddddd <img src=\"/dddsfdsfsdfsdfsdfsdfsdsdfsd.gif\"/> ddd <img src=\"/dddsfdsfsdfsdfsdfsdfsdsdfsd.jpg\" />";
int offset = 0;
while (offset < a.Length)
{
int swap = a.IndexOf("<img", offset);
if (swap == -1)
{
break;
}
int temp1 = a.IndexOf("src=", swap);
int temp2 = a.IndexOf(">", swap);
if (temp2 <= temp1)
{
continue;
}
string str = a.Substring(temp1 + 4,temp2 - temp1 - 4);
temp1 = str.IndexOf(" ");
if (temp1 != -1)
{
str = str.Substring(0, temp1);
str = str.Replace("\"", "");
}
else
{
temp1 = str.IndexOf("\"");
str = str.Substring(temp1+ 1,str.IndexOf("\"",temp1 + 1) - temp1 - 1);
}
result.Add(str);
offset = temp2 + 1;