Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add a space/split up pairs of characters

How do you add a space/split up between each pair of characters.

eg 0x5C8934A3   -->  0x 5C 89 34 A3

I could use a macro but it just took to long to manualy set it up because the size of the strings.

what i know is how to find using. but i can not get the replace to work correctly Please show me how to preform this.

[0][x][0-9A-F]+    
match 
0x5C8934A3
like image 852
david Avatar asked Sep 20 '11 06:09

david


2 Answers

Notepad++ has very limited regexes so you have to use something like this:

Search for

(..)

and replace with

\1 

(Note there is a space after the \1!)

(..) means find two characters and store them

\1 get the characters stored in the first capturing group

Precondition for this simple solution is that there are only such strings and nothing else. And it will then add an unneeded space after the word. If this is not not wanted you can remove it afterwards.

like image 104
stema Avatar answered Sep 23 '22 00:09

stema


I don't have Notepad++ installed here, but on my editor you can search for \B(?=(?:[0-9A-F]{2})+\b) and replace all with a single space.

Explanation:

\B            # only match within words
(?=           # Assert that from the current position...
 (?:          # ...the following can be matched:
  [0-9A-F]{2} # a succession of two hexadecimal digits
 )+           # once or more,
 \b           # ending at a word boundary.
)             # End of lookahead
like image 26
Tim Pietzcker Avatar answered Sep 25 '22 00:09

Tim Pietzcker