Eliminate non-displayable characters

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
dbthj
Posts: 11
Joined: Fri Oct 09, 2009 1:49 pm

Eliminate non-displayable characters

Post by dbthj »

I'm looking through my regex doc and trying to figure out how to elimiate nondisplayable characters except spaces and carriage return.

I'm not having any luck. I figured I could change all spaces to some wierd combination of letters. Then do the same for carriage return. Then if I could just null out any other wierd non-dispayable characters, I could replace the wierd stuff with spaces and carriage returns.

My doc says [:space:] is spaces, tabs, and formfeeds.
It say [:cntrl:] other control characters.
But if I replace those with nulls, all hell breaks loose. Either the doc
is wrong or I'm not reading it right.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

The regex for white space is [[:space:]] (that is, [...] with [:space:] inside it).

How are you inserting nulls? I know of no way to get TextPad to insert a null into a document.

To remove all characters except ASCII printables (\x20 .. \x7E, that is, space to ~), try
Search | Replace... (<F8>):
Find what: [^ -~]
Replace with: [nothing]

[X] Regular expression

Replace All
dbthj
Posts: 11
Joined: Fri Oct 09, 2009 1:49 pm

Post by dbthj »

Thanks, that seems to work, though it doesn't solve my problem.

I am editing some Netbackup command files with a textpad macro to save me a whole lot of typing an typos in restoring a whole bunch of databases backed up by Netbackup.

When I run them, nothing happens. Our local Netbackup expert says, "Oh, you can't use Textpad. You have to use Notepad". Well, I figured Textpad was introducing some wierd non-displayable characters that Netbackup doesn't like. So I created a macro to get rid of them.
No luck. Textpad is doing something strange.

Anyhow, the way I replace a string with a null (delete them) is to do a replace and make sure I have nothing typed in the "Replace with" field. That has always served me well, but in light of this problem, maybe it does something I don't like.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

"Oh, you can't use Textpad. You have to use Notepad" is nonsense. They are both just text editors. Textpad doesn't introduce any characters, let alone weird non-displayable ones, that you haven't explicitly told it to introduce.

Null is not nothing. It is a well-defined character: the one whose code is 0.

You haven't provided enough information for us to be able to help you. Are you editing existing files or creating new ones from scratch? Are you running Netbackup on Windows or Unix?
dbthj
Posts: 11
Joined: Fri Oct 09, 2009 1:49 pm

Post by dbthj »

Nonsense. That's what I thought. Then I tried editing the Netbackup batch code manually (without macros) in the same way I do with Notepad and sure-enough. Netbackup would not use it. I won't pretend that Netbackup is a robust, will engineered, easy-to-use product, but I'm stuck with it.

I was unaware that Hex zeros and null were the same. I guess I lied.

As for my inability to use Textpad, I know not what's going on - perhaps inadvertent ANSI/Unicode conversion. Beats me. But I don't have time to test and pursue.

Thanks for your input
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Have you tried opening the working and non-working versions in binary mode to see what the difference is?
File format: Binary
Post Reply