Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++ Insert characters every 2 characters of a string [duplicate]

I have a string representing hex numbers, like this:

778206213082061D06092A

I want to get a string like this:

0x77, 0x82, 0x06, 0x21, 0x30, 0x82, 0x06, 0x1D, 0x06, 0x09, 0x2A

So every 2 characters, I want to insert , 0x Is this doable with Notepad++?

like image 282
tzippy Avatar asked Jan 25 '17 13:01

tzippy


2 Answers

Try this:

Find:

(..)

Replace:

0x\1, 

The find expression (..) matches any two characters (dot matches anything), and the parenthesis allow us to capture those two characters. We can then replace with the hex expression, accessing those two captured characters by using \1 (or $1; Notepad++ will accept either). Note that there is a space after the comma in the replacement.

like image 94
Tim Biegeleisen Avatar answered Nov 29 '22 13:11

Tim Biegeleisen


How about:

  • Ctrl+H
  • Find what: (..)
  • Replace with: 0x$1,
  • Replace all

You have then to remove the last , if requested.

like image 27
Toto Avatar answered Nov 29 '22 13:11

Toto