日期:2014-05-18  浏览次数:20423 次

如何截取这样的字段
我想在读取的字段数据中,截取第一个图片的路径/upshop/201109/24100019201.jpg,请问如何截取啊


<p>
 龙年买恐龙</p>
<p style="text-align: center">
 <img alt="恐龙" src="/upshop/201109/24100019201.jpg" style="width: 550px; height: 413px" /></p>
<p style="text-align: center">
 <img alt="恐龙" src="/upshop/201109/24100019592.jpg" style="width: 600px; height: 450px" /></p>
<p style="text-align: center">
 <img alt="恐龙" src="/upshop/201109/24100019543.jpg" style="width: 600px; height: 450px" /></p>
<p style="text-align: center">
 <img alt="恐龙" src="/upshop/201109/24100019934.jpg" style="width: 550px; height: 413px" /></p>
<p style="text-align: center">
 &nbsp;</p>


------解决方案--------------------
C# code

string input = @"<p>
 龙年买恐龙</p>
<p style=""text-align: center"">
 <img alt=""恐龙"" src=""/upshop/201109/24100019201.jpg"" style=""width: 550px; height: 413px"" /></p>
<p style=""text-align: center"">
 <img alt=""恐龙"" src=""/upshop/201109/24100019592.jpg"" style=""width: 600px; height: 450px"" /></p>
<p style=""text-align: center"">
 <img alt=""恐龙"" src=""/upshop/201109/24100019543.jpg"" style=""width: 600px; height: 450px"" /></p>
<p style=""text-align: center"">
 <img alt=""恐龙"" src=""/upshop/201109/24100019934.jpg"" style=""width: 550px; height: 413px"" /></p>
<p style=""text-align: center"">
 &nbsp;</p>";
            Regex rgx = new Regex(@"(?is)(?<=src="")[^""]+?(?="")");
            Console.WriteLine(rgx.Match(input));

------解决方案--------------------
探讨

C# code

string input = @"<p>
龙年买恐龙</p>
<p style=""text-align: center"">
<img alt=""恐龙"" src=""/upshop/201109/24100019201.jpg"" style=""width: 550px; height: 413px"" /></p>
<p style=""text-align: ……

------解决方案--------------------
探讨

C# code

string input = @"<p>
龙年买恐龙</p>
<p style=""text-align: center"">
<img alt=""恐龙"" src=""/upshop/201109/24100019201.jpg"" style=""width: 550px; height: 413px"" /></p>
<p style=""text-align: ……

------解决方案--------------------

<p>
 龙年买恐龙</p>
<p style="text-align: center">
 <img alt="恐龙" src="/upshop/201109/24100019201.jpg" style="width: 550px; height: 413px" /></p>
<p style="text-align: center">
 <img alt="恐龙" src="/upshop/201109/24100019592.jpg" style="width: 600px; height: 450px" /></p>
<p style="text-align: center">
 <img alt="恐龙" src="/upshop/201109/24100019543.jpg" style="width: 600px; height