Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8779321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:45:27+00:00 2026-06-13T19:45:27+00:00

This is a vexing one. I had a block of text coming from a

  • 0

This is a vexing one. I had a block of text coming from a Beyond Compare script report.

Picture Compare
Produced: 10/17/2012 9:42:25 AM
Ignoring Unimportant
Left file: K:\HDA_FIN\user\JMan\All\A-0001.jpg     Right file: K:\HDA_FIN\user\JMan\All\B-0001.jpg
3454945 same pixel(s)
2154 ignored unimportant difference pixel(s)
2741 important difference pixel(s)

This repeats over and over as the script compares mated jpegs in the folder. But some jpegs are 100% the same, so they have no ignored unimportant or important differences. And some will have same differences and important differences, but no unimportants, and etc. So I am trying to capture matches that start with “Picture Compare” and end with the LAST “pixel(s)” before the next “Picture Compare” starts again.

What I have tried:

What is am doing not is an ugly method: I use a stream reader, and while !EndOfStream, I perform sr.ReadLine() and add each line to a List. I then use a for loop to iterate through the list and apply a series of if statements to determine whether the current string in the loop and the next few ahead match what I am looking for, and if so, I bind them to an object. But surely Regex is much simpler.

    var lineByLine = new List<string>();
    while (!sr.EndOfStream)
    {
        string line = sr.ReadLine();
        sb.AppendLine(line);
        if (line.Trim().Length > 0)  // && !line.Contains("picture-report layout"))
        {
            lineByLine.Add(line);
        }
    }

    Contents = sb.ToString();

    //get the report blocks


    for (int i = 0; i < lineByLine.Count; i++)
    {
        Block block;
        string[] lines = { "", "", "", "", "", "", "" };

        //does line contain pic compare? if so, this is the start of an object
        if (lineByLine[i].Contains("Picture Compare"))
        {
            lines[0] = lineByLine[i]; //start line
            block = new Block();
            lines[1] = lineByLine[i + 1]; //produces
            lines[2] = lineByLine[i + 2]; //subheading
            if (lineByLine[i + 3].Contains("Left"))
            {
                lines[3] = lineByLine[i + 3]; //file
                if (lineByLine[i + 4].Contains("same pixel(s)"))
                {
                    lines[4] = lineByLine[i + 4]; //same
                    if (lineByLine[i + 5].Contains("ignored unimportant"))
                    {
                        lines[5] = lineByLine[i + 5];
                        if (lineByLine[i + 6].Contains(" important difference"))
                        {
                            lines[6] = lineByLine[i + 6];
                        }
                    }
                }
                else if (lineByLine[i + 4].Contains("ignored unimportant"))
                {
                    lines[5] = lineByLine[i + 4];
                    if (lineByLine[i + 5].Contains(" important difference"))
                    {
                        lines[6] = lineByLine[i + 5];
                    }
                }
                else if (lineByLine[i + 4].Contains(" important difference"))
                {
                    lines[6] = lineByLine[i + 4];
                }
            }
            Blocks.Add(new Block(lines[0], lines[1], lines[2], lines[3], lines[4], lines[5], lines[6]));
        }
    }

}
finally
{
    sr.Close();
}

This works, but I am trying to refactor and make it cleaner. I tried this:

 var matches = Regex.Matches(cr.Contents, "(Picture Compare)(.*?)(pixel)", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture);

-but it stops at same pixels in all cases. I need something greedier. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:45:29+00:00Added an answer on June 13, 2026 at 7:45 pm

    Instead of finding the end you could try to find the next start:

    @"Picture Compare(?:(?!Picture Compare).)*"
    

    This matches Picture Compare and then as many characters as possible, as long as they don’t start a new Picture Compare (this is what the negative lookahead is for). This should simply give you all those blocks.

    Then on each of those blocks, you can do a lot simpler scanning to get the values you are interested in (unfortunately, I don’t know which ones that are, otherwise I might have another regex for those as well :P).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one is really vexing me, hopefully someone can figure out what is going
This should be a simple one: I have an observableArray object called To in
This is my code: <CheckBox android:id=@+id/sprint_checkbox android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/sprint_game /> <CheckBox android:id=@+id/marathon_checkbox android:layout_width=fill_parent android:layout_height=wrap_content
ASP.NET 4.0 Need some help with this vexing HTTP POST problem - I have
This seems like such a trivial question to ask, but it's been vexing me
This question is taken from an exam. I don't know how to do that.
This one works items = Item.where(:item_id.in => items.map(&:id)) unlike these two items = Item.where(item_id:.in
This problem has been vexing me for a little over a day. The gist
This Ruby on Rails problem is a bit vexing, as the code works fine
Basically this is a follow up of this question about most vexing parse. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.