Announcement

Collapse
No announcement yet.

Replacements on hex addresses

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

  • Replacements on hex addresses

    Hi,

    I have on my left addresses that consist of 8 hexadecimal digits. On the right, addresses that have '0x' followed by 8 hexadecimal digits (usually different from those in the left.

    I want these blocks of addresses to be considered unimportant changes.

    I tried the replacement:
    Left: [0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]
    Right: 0x[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]

    However, this didn't work. What's the way to do this?

    Cheers,
    PM

  • #2
    Hello,

    This forum post may have some information useful for you:
    http://www.scootersoftware.com/vbull...ead.php?t=4546

    Text Replacements cannot match on a mask on the "right"/destination side. For your replacement to work, the two 8 digit sets would need to match. Otherwise, you may want to define two different Unimportant Grammars:
    http://www.scootersoftware.com/suppo..._unimportantv3

    How does that work for you?
    Aaron P Scooter Software

    Comment


    • #3
      Better to create a single unimportant case-insensitive grammar with the leading "0x" defined as optional so that the detected grammar element on both sides is the same. Here is a grammar definition that might work for you:

      (?:0x){0,1}[0-9a-f]{8}

      (?: ) Groups characters without creating a back reference. The grouped text is "0x"
      {0,1} Repeats prior grouped characters 0 to 1 times
      [0-9a-f] Creates a character class for a hexidecimal digit
      {8} Repeats prior class 8 times
      BC v4.0.7 build 19761
      ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

      Comment


      • #4
        Scooter - I just tried the regex expression I provided above.
        Although it works fine in a regex find/replace operation, it errors when used in a grammar definition: "Invalid regular expression: Character expected at position 2"

        Since this is not an invalid regular expression, I am wondering why it is not allowed in a grammar definition?

        PMatos - You'll have to try this instead:

        (0x){0,1}[0-9a-f]{8}

        It works the same way... the only difference is that it creates an unnecessary back reference to the 0x characters if they are present.
        BC v4.0.7 build 19761
        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

        Comment


        • #5
          The regular expression engine used in the comparison and syntax highlighting only supports a limited subset of the full regular expression syntax. Back references are one of the things it doesn't support, so ?: isn't supported either. Erik handled that work, so I don't know the specifics, but we can't use PCRE like we are in the Find dialog.
          Zoë P Scooter Software

          Comment


          • #6
            Thanks Craig. It sounds like (Ox) in a grammar rule is the same as (?:Ox) in PCRE. That should work fine, then.
            BC v4.0.7 build 19761
            ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

            Comment


            • #7
              Thank you all for your help. With your tips I got it working just as I wanted.

              Cheers,

              PM

              Comment

              Working...
              X