none
PostScript parser Regular Expression RRS feed

  • 問題

  • Hi,

    i try to parse postscript file.I want to get all string between %%BeginResource: font and %%EndResource.
    i create a pattern like this. (%%BeginResource: font\s.*)(.+)*[^(%%EndResource)] But it isn't work.

    thanks in advance

    selçuk
    2009年6月4日 下午 01:16

解答

  • if you just want get the content between "%%BeginResource: font" and "%%EndResource", try this:
    Regex regex = new Regex(@"%%BeginResource:\s*font\s*(?<content>.*?)%%EndResource", RegexOptions.Singleline);
    MatchCollection matchCols = regex.Matches(File.ReadAllText("your file path"));
    foreach (Match match in matchCols)
    {
        Console.WriteLine(match.Groups["content"].Value);
    }
    or you want the content includes "%%BeginResource: font" and "%%EndResource", try this:
    Regex regex = new Regex(@"%%BeginResource:\s*font\s*.*?%%EndResource", RegexOptions.Singleline);
    MatchCollection matchCols = regex.Matches(File.ReadAllText("your file path"));
    foreach (Match match in matchCols)
    {
        Console.WriteLine(match.Value);
    }
    • 已標示為解答 selcukyazar 2012年10月8日 下午 12:43
    2009年6月6日 上午 01:38