我的第一想法:用substring找到.jpg,在提取其前面的数字。
好像没正则好哦,呵呵

解决方案 »

  1.   


            //自己优化下吧是否只能是.jpg或者。
            static void Main(string[] args)
            {
                string str = "<img src=\"fish.jpg\" style=\"width: 60px; height: 60px\" /> <img alt=\"\" src=\"47.jpg\" style=\"width: 200px; height: 200px\" > </img>";
                foreach (string var in str.Split('"'))
                {
                    if (var.IndexOf(".jpg") > 0)
                    {
                        Console.WriteLine(var);
                    }
                }
                Console.ReadLine();
            }
      

  2.   

    String str="fish.jpg\" style=\"width: 60px; height: 60px\" /> <img alt=\"\" src=\"47.jpg\" style=\"width: 200px; height: 200px\" > </img>";        Regex objRegex = new Regex(@"\w{1,}\.jpg",RegexOptions.IgnoreCase);
            MatchCollection objCollection=   objRegex.Matches(str);
            foreach (Match objItem in objCollection)
            {
                Response.Write(objItem.Value + "<Br/>"); 
            }
    结果:
    fish.jpg
    47.jpg
      

  3.   

    正则,匹配"开头, .jpg 尾.