KcFnMi
KcFnMi

Reputation: 6191

Put space every two characters in text string

Given the following string:

6e000000b0040000044250534bb4f6fd02d6dc5bc0790c2fde3166a14146009c8684a4624

Which is a representation of a Byte array, every two characters represent a Byte.

I would like to put a space between each Byte using Sublime Text, something like:

6e 00 00 00 b0 04 00 00 04 42 50 

Does Sublime Text help me on that issue?

As a bonus I would like to split into lines and add 0x before each Byte.

I found a similar question but that's not related no Sublime Text, Split character string multiple times every two characters.

Upvotes: 3

Views: 6868

Answers (2)

garyh
garyh

Reputation: 2852

To split it onto separate lines and add 0x before each byte do this:

Find (.{2})

Replace with: 0x\1\n

Upvotes: 2

user977221
user977221

Reputation:

Go to Find->Replace... and enable regular expressions.

Replace: (.{2})

With: $1SPACE

Where SPACE is a space.

Upvotes: 6

Related Questions