正则表达取得 image src 中值

var context = "<img src=http://www.google.com/aaaaa/image_1 /><img src=\"http://www.google.com/aaaaa/image_1\" /><img src='http://www.google.com/aaaaa/image_1' /><img src='aaaaa' /><img src='aaaaa' />";
            var pattern = "<img[^>]*src\\s*=\\s*['\"]?([\\w/\\-\\.\\:_]*)['\"]?[^>]*";
            var matches = Dev.Comm.RegexHelper.MatchesGroupsString(context, pattern, 1);

            //var local = matches.Where(x => Dev.Comm.Web.UrlHelper.IsUrlLocalToHost(x));
            foreach (var match in matches)
            {
                Console.WriteLine(match);
            }

posted @ 2013-05-07 15:26  张保维  阅读(170)  评论(0编辑  收藏  举报