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

C#的一个正则问题
麻烦各位帮忙写一个正则。我想取出
pic[0] = 'imgs/DM/A/alsxy/00000/001.jpg';
…………
pic[16] = 'imgs/DM/A/alsxy/00000/017.jpg';
的图片信息。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>爱丽丝学院番外篇01 爱丽丝学院漫画 动漫宅基地</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="爱丽丝学院番外篇01 爱丽丝学院漫画 动漫宅基地"/>
<meta name="Description" content="动漫宅基地为您提供更新最新速度最快的爱丽丝学院漫画番外篇01,看爱丽丝学院漫画,就来动漫宅基地爱丽丝学院漫画网"/>
<link href="/css/pcss.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/scripts/history.js"></script>
<SCRIPT>
var prev_page = '/comic/3065/3207.html?page=29';
var next_page = '/comic/3065/3209.html';
var book_mc = '爱丽丝学院';
var pic = new Array();
pic[0] = 'imgs/DM/A/alsxy/00000/001.jpg';
pic[1] = 'imgs/DM/A/alsxy/00000/002.jpg';
pic[2] = 'imgs/DM/A/alsxy/00000/003.jpg';
pic[3] = 'imgs/DM/A/alsxy/00000/004.jpg';
pic[4] = 'imgs/DM/A/alsxy/00000/005.jpg';
pic[5] = 'imgs/DM/A/alsxy/00000/006.jpg';
pic[6] = 'imgs/DM/A/alsxy/00000/007.jpg';
pic[7] = 'imgs/DM/A/alsxy/00000/008.jpg';
pic[8] = 'imgs/DM/A/alsxy/00000/009.jpg';
pic[9] = 'imgs/DM/A/alsxy/00000/010.jpg';
pic[10] = 'imgs/DM/A/alsxy/00000/011.jpg';
pic[11] = 'imgs/DM/A/alsxy/00000/012.jpg';
pic[12] = 'imgs/DM/A/alsxy/00000/013.jpg';
pic[13] = 'imgs/DM/A/alsxy/00000/014.jpg';
pic[14] = 'imgs/DM/A/alsxy/00000/015.jpg';
pic[15] = 'imgs/DM/A/alsxy/00000/016.jpg';
pic[16] = 'imgs/DM/A/alsxy/00000/017.jpg';
</SCRIPT>
</head>
<body leftmargin="0" topmargin="0" style="background:none;">
<div class="nr_t h_bai">

------解决方案--------------------
C# code
        string s = File.ReadAllText(Server.MapPath("~/test.txt"));
        MatchCollection matches = Regex.Matches(s, @"(?is)pic\[\d+\]\s=\s'[^']+'");
        foreach (Match match in matches)
            Response.Write(match.Value + "<br/>");