117

I have got characters like that in my notepad++

npp screenshot of NULs

When i am trying to copy whole line, i am actually copying everything until "NUL":

File:1

What i want to do, is replace those null, to be nothing, so i can copy my whole line. Maybe there is any keyword that will tell notepad++(or any other program that might help) to replace those characters? When i am selecting it, use Right Click and then "clear", its gone - but i dont want to do it one by one.

I don't care about removing the cause of this problem, just the effect(NULs)

matt wilkie
  • 17,268
  • 24
  • 80
  • 115
user2618929
  • 1,591
  • 4
  • 13
  • 14

7 Answers7

140

This might help, I used to fi my files like this: http://security102.blogspot.ru/2010/04/findreplace-of-nul-objects-in-notepad.html

Basically you need to replace \x00 characters with regular expressions

enter image description here

Ro Yo Mi
  • 14,790
  • 5
  • 35
  • 43
Aleksandr
  • 2,185
  • 2
  • 21
  • 29
  • 9
    Please note, you shuold try "\x00", "\00", or "\0". For me, \x00 and \00 did not work. I needed to use \0 for the replace character. – Hooplator15 Dec 06 '16 at 21:00
  • 1
    @JohnAugust thank you so much for this. \x00 kept finding 'normal' spaces as well as the NUL characters. – Steffen Winkler Dec 14 '17 at 09:34
  • Thx wanted to search a .dmp file for a blok of multi-line text. however unfortunately notepad crashed for me probaly becuase of the size of the dump – Mellester Mar 06 '18 at 15:09
42

Click Search --> Replace --> Find What: \0 Replace with: "empty" Search mode: Extended --> Replace all

user4247816
  • 421
  • 4
  • 2
  • What is the extended for?? – rooni Dec 15 '17 at 13:13
  • @rimiro extended in the sense that specially escaped characters (basic regular expression metacharacters like \n et cetera) can be matched against rather than simply the characters typed. – twobob Feb 20 '18 at 01:15
15

I was having same problem. The above put me on the right track but was not quite correct in my case. What did work was closely related:

  • Open your file in Notepad++
  • Type Control-A (select all)
  • Type Control-H (replace)
  • In 'Find What' type \x00
  • In 'Replace With' leave BLANK
  • In 'Search Mode' Selected 'Extended'
  • Then Click on 'Replace All'
Mark Jeronimus
  • 9,278
  • 3
  • 37
  • 50
user914945
  • 161
  • 1
  • 3
  • Selecting all text (second bullet) is not needed, solution works well with or without it :) – Piemol Aug 08 '23 at 08:25
7

Try Find and Replace. type \x00 in Find text box, check the Regular expression option. Leave Replace textbox blank and click on replace all. short cut key for find and replace is ctrl+H.

Miller
  • 1,096
  • 9
  • 22
  • 6
    find with \x00. You may require to check the Regular expression option. – Miller Oct 12 '13 at 10:17
  • You have to use a regular expression, this answer is wrong since obviously you can copy past a special char just like that – mahieddine Sep 07 '15 at 08:53
  • I was giving the answer as per SO's question, he is asking on notepad++ not notepad. I dont why people down vote on my answer and other people are upvoiting the answer by AlexShumilov. – Miller Jul 01 '16 at 12:35
4

I tried to use the \x00 and it didn't work for me when using C# and Regex. I had success with the following:

//The hexidecimal 0x0 is the null character  
mystring.Contains(Convert.ToChar(0x0).ToString() );  

// This will replace the character
mystring = mystring.Replace(Convert.ToChar(0x0).ToString(), "");  
Lee Harris
  • 521
  • 4
  • 12
  • 1
    What does this have to do with Notepad++? – ChrisWue Jan 20 '20 at 17:30
  • OP asked about notepad++ or any other program that might help. Could you please update the answer with some extra code to make it complete so that it could help others newbie in .Net (i. e. read text file from drive, replace nul chars, save back to text file, I mean something like [this](https://superuser.com/a/968513), and instructions how to launch C# code without VS, e.g. just using csc.exe). – omegastripes Oct 21 '20 at 08:30
2

Open Notepad++
Select Replace (Ctrl/H)
Find what: \x00
Replace with:
Click on radio button Regular expression
Click on Replace All

-1

Highlight a single null character, goto find replace - it usually automatically inserts the highlighted text into the find box. Enter a space into or leave blank the replace box.

Gavin
  • 2,123
  • 1
  • 15
  • 19
  • 8
    This does not work with the NUL character in Notepad++. It does work with many other ASCII special characters, such as BEL, but NUL can only be found using Extended escape codes or RegEx. – Ayelis Jul 31 '15 at 19:31