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

这个正则表达式如何写?
对于下面的字符串,我想分别获取冒号后的信息,如何写正则表达式

Content-Type: application/msword;
  name="readme.doc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
  filename=" readme.doc "


------解决方案--------------------
看看这个能否达到要求
C# code
 Regex reg = new Regex(@"(?<=[::""][\s\t]*)[^\n"";;\s]+(?=[\s\t]*[;"";\n])");
            string input = @"Content-Type: application/msword;
  name=""readme.doc""
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
  filename="" readme.doc """;
            foreach (Match m in reg.Matches(input))
                Console.WriteLine(m.Value);

//print
application/msword
readme.doc
base64
attachment
readme.doc