Author Topic: How to search and replace single Hex Character (4bit nibble) in binary edit mode  (Read 553 times)

ADI8421

  • New Community Member
  • Posts: 2
  • Hero Points: 0
How to search and replace single Hex Character (4bit nibble) in binary edit mode ?
To search for 0xCD for example, I can search whole bytes using \xCD, but is it possible to search and 'replace all' single nibbles without overwriting the other nibble in each the byte ? Many thanks
« Last Edit: December 04, 2018, 10:26:08 pm by ADI8421 »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5052
  • Hero Points: 418
This will work nicely IF there are not that many matches to be translated. Make sure your encoding is ACP and NOT a unicode encoding like Utf-8. Choose to open the file with "Text, SBCS/DBCS mode" if you need to.

Search For:
(\xca)|(\xcb)|(\xcc)|(\xcd)

Replace With:
$(<1>\x1a|<2>\x1b|<3>\x1c|<4>\x1d)

Turn on Perl syntax regular expressions

Depending on which match group is found, a different replacement occurs.

If the above doesn't work, you'll have to write a macro. If you do write a macro, make sure to specify the "y" search option so the encoding of the file doesn't matter as long as it's ACP or Utf-8. Unfortunately, SlickEdit's GUI doesn't yet support the "y" (binary/byte) search option.
 

ADI8421

  • New Community Member
  • Posts: 2
  • Hero Points: 0
Wow !  It worked.  This is powerfull.  Thankyou so much. Just what I need.
Best regards
Jim
PS: Works fine with 15 entries which is all I needed.
« Last Edit: December 05, 2018, 03:08:58 am by ADI8421 »