Search code examples
regexnotepad++

notepad++ regex mode: insert new line to some hex code


i have hex code below. the regex find code can match the string, but replace code wont keep the original string. my question : how to fix replace code to keep original string. thx

hex txtfile:
5839343C12050D000020410A2B
B81E053E12050D0000A0410A2B
0AD7A33C12050D000020420A2B

replace txtfile :
5839343C
12050D000020410A2B
B81E053E
12050D0000A0410A2B
0AD7A33C
12050D000020420A2B

notepad++ regex code :
find--12050D0000.*04.0A2B\s
replace-- \n012050D0000.*04.*0A2B\n


Solution

  • To retain the input text use capture groups.

    Use a find text of (12050D0000.*04.0A2B)\s and replace with \n\1\n. Ensure that "Regular expressions" is selected.

    Note that this simple replacement can add unwanted blank lines if "Replace all" is pressed more than once. To avoid that I would suggest a more complex replacement:

    Find (\w)(12050D0000.*04.0A2B)\s and replace with \1\n\2\n.