Replacing nulls

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
XXPepper
Posts: 2
Joined: Thu Jul 05, 2012 11:23 pm
Location: United States
Contact:

Replacing nulls

Post by XXPepper »

I need to replace a string several thousand times in index files for a set of many thousands of PDF files. Unfortunately the word "chronicle" was misspelled as "chronicale". The files are renamed, now need to fix the indexes.

The characters are separated by NULL, \x00.

n\x00i\x00c\x00a\x00l\x00e

I've been able to find the string OK, in various forms, including, e.g.,

n\(\x00\)i\(\x00\)c\(\x00\)a\(\x00\)l\(\x00\)e

or another where every character was tagged.

The "a\x00" pair needs to be removed.

I've tried a replacement string like;

n\(\1\)i\2c\3l\4e

but in every case the only character that goes into the replacement is the "n".

Any ideas or tips would be most welcome.

Thanks.
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post by ak47wong »

TextPad doesn't appear to be able to handle null characters in the replacement string. As soon as it encounters the null after the "n", the string is terminated.

Just a tip: if you enable POSIX regular expression syntax in Preferences (under Editor), you don't need all those backslashes before the parentheses in the search string; you can just type n(\x00)i(\x00)c(\x00)a(\x00)l(\x00)e.

Since the string you're capturing in the parentheses is the same in each group, you only have to capture the first one: n(\x00)i\x00c\x00a\x00l\x00e.

You also don't need the parentheses in the replacement expression.

Not that that fixes your problem, sorry.
XXPepper
Posts: 2
Joined: Thu Jul 05, 2012 11:23 pm
Location: United States
Contact:

Post by XXPepper »

ak47wong wrote: Since the string you're capturing in the parentheses is the same in each group, you only have to capture the first one: n(\x00)i\x00c\x00a\x00l\x00e.
Desperation lead to trying to replace 1 and 2 and so on.
ak47wong wrote:You also don't need the parentheses in the replacement expression.

Not that that fixes your problem, sorry.
Desperation again. I was trying everything I could think of. This is the first time that I've ever been let down by TextPad on anything.
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Post by kengrubb »

What if you first replaced all the Null (\x00) characters with something else?

Like ÿ (\xFF)

Obviously you would need to ensure the character you used was not already in the file.

If you need to change back to Null when you're done, I do not believe that is possible for TP. However, WE (WildEdit) will let you change from \xFF to \x00 in a single file.
(2[Bb]|[^2].|.[^Bb])

That is the question.
Post Reply