Search code examples
notepad++endianness

Notepad++ - swap endianess of values in text file


I have text file filled with hex values, six at each line, like this:

0XC71F2A11 0X46776208 0X448659B3 0X00000000 0X00000000 0XBFC3BAD1
0XC7122457 0X4680A201 0X448659B3 0X00000000 0X00000000 0XBFC3BAD1
0XC7147823 0X46756BD2 0X448659B3 0X00000000 0X00000000 0X3FCE418B
0XC7144C13 0X46814776 0X448659B3 0X00000000 0X00000000 0X3FCE418B

I need to swap endianess of every value, for example 0XC71F2A11 -> 0X112A1FC7


Solution

  • You can use the find & replace function with regular expressions:

    Find: (0X)([A-F0-9]{2})([A-F0-9]{2})([A-F0-9]{2})([A-F0-9]{2})

    Replace: \1\5\4\3\2

    Screenshot

    [A-F0-9] matches a single character between A and F or between 0 and 9.