Announcement

Collapse
No announcement yet.

Ignoring line 2 of a file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ignoring line 2 of a file

    Using BC4-64 bit, how can I ignore line 2 of a text file in comparisons? We have a file format where line 2 is exactly 64 characters and is a checksum of data that includes the date/time of when the file was generated. The rest of the file is easy to handle with BC's file format grammar rules.

    Setting a grammar rule that a regular expression of "^\w{64}$" is a comment almost works, but risks matching on other lines that happen to be 64 alphanumerics.

    Another way that almost works has a comment grammar element with "Lines" plus an empty "Text matching" plus a tick on "or line 1" plus the next 1 lines. We can put up with this ignoring line 1 as well. My problem with this rule is why does it work? What does an empty "Text matching" field actually look for? I understand that the "lines" category works well for page headers so I worry that the empty field will match something later in the file and ignore two lines there.

  • #2
    Hello,

    For the "Lines" element type, it is to begin on "Text Matching" or "Line 1". The key is the OR statement. If you leave Text Matching blank, then it only matches on Line 1. By defining Text Matching and enabling Line 1, it will do both. By selecting Line 1, it's a hardcoded start point, while Text Matching can match on any specific line in your file, and then set to define the next X lines. This element does not allow defining the start line (line 2). If you can ignore Line 1 and Line 2, you could set this (as you found) to start at line 1 and go for the next 1 lines to define those two.

    To match only on line 2, it would need to match on the hash as a definition, like you created with that regular expression. It sounds like you worry that hash lines might appear elsewhere in the file however, so the Lines element (grabbing 1 and 2) sounds like the best method. Normally, I'd ask if there's any way to define the RegEx to be more specific (so it can always match on Line 2 and never anything else), but it sounds like you've accounted for that already.
    Aaron P Scooter Software

    Comment


    • #3
      Thank you, Aaron, for the detailed explanation of how the "lines" element type works.

      Comment

      Working...
      X