Replace hex with hex
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
hexadoodle
- Posts: 5
- Joined: Wed Feb 06, 2008 8:53 pm
Replace hex with hex
I have an ascii file. I want to replace hex 01 through hex 1F and
hex 7F through hex FF with hex 20 (space).
I have searched and read and tried and not been successful.
Creating a macro for the find/replaces is totally acceptable.
I just did not want to do it one hex character at a time.
THANKS.
hex 7F through hex FF with hex 20 (space).
I have searched and read and tried and not been successful.
Creating a macro for the find/replaces is totally acceptable.
I just did not want to do it one hex character at a time.
THANKS.
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
Use the pipe character for OR searches.
Try something like this untested example:
Search for: [\x01|\x02|\x03|.........|\xFF]
Replace with: \x20
----------------------------------
Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------
Try something like this untested example:
Search for: [\x01|\x02|\x03|.........|\xFF]
Replace with: \x20
----------------------------------
Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------
Last edited by Bob Hansen on Thu Feb 07, 2008 2:17 am, edited 1 time in total.
Hope this was helpful.............good luck,
Bob
Bob
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
That's not right. You don't want the square brackets; they turn the whole thing into a character class, which will match any one character that is \ or x or 0 or 1 or | or ... Just leave the square brackets out.
Alternatively, use a character class ( [...] ) and enter each required control character by holding down the Alt key while typing zero followed by the character's numeric value (in decimal) on the numeric keypad:
for hex 01 use Alt-01
for hex 1F use Alt-031
for hex 7F use Alt-0127
for hex FF use Alt-0255
Like this:
[<Alt-01>-<Alt-031><Alt-0127>-<Alt-0255>]
That contains exactly 2 hyphens, and <Alt-01> represents the single character hex 01, and so on, entered as explained above.
You can use a simple space character in the replacement, instead of \x20.
Alternatively, use a character class ( [...] ) and enter each required control character by holding down the Alt key while typing zero followed by the character's numeric value (in decimal) on the numeric keypad:
for hex 01 use Alt-01
for hex 1F use Alt-031
for hex 7F use Alt-0127
for hex FF use Alt-0255
Like this:
[<Alt-01>-<Alt-031><Alt-0127>-<Alt-0255>]
That contains exactly 2 hyphens, and <Alt-01> represents the single character hex 01, and so on, entered as explained above.
You can use a simple space character in the replacement, instead of \x20.
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
Aargh!That's not right. You don't want the square brackets; they turn the whole thing into a character class, which will match any one character that is \ or x or 0 or 1 or | or ... Just leave the square brackets out.
You are right (of course).
Thanks ben_josephs, I knew you would have the correct answer. 8)
Hope this was helpful.............good luck,
Bob
Bob
-
hexadoodle
- Posts: 5
- Joined: Wed Feb 06, 2008 8:53 pm
Don't Let Go Yet, I'm Pedaling as Fast as I Can
I tried the alt sequence, both hold down alt and enter 001 etc
also hold down alt 0, then let alt go and 01 etc
with posix on and off and regular expression on and off
get error msgs cannot find literal expression or
invalid regular expression I would like to get this one correct,
it is simpler, however not easier for me
the \x01|\x02 ... works, however that's a lot of keystrokes and
about 5 people need
to create this macro and they had mistakes with instructions
on making a macro that replace hex 09 with hex 20
Thanks for your patience
also hold down alt 0, then let alt go and 01 etc
with posix on and off and regular expression on and off
get error msgs cannot find literal expression or
invalid regular expression I would like to get this one correct,
it is simpler, however not easier for me
the \x01|\x02 ... works, however that's a lot of keystrokes and
about 5 people need
to create this macro and they had mistakes with instructions
on making a macro that replace hex 09 with hex 20
Thanks for your patience
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
-
hexadoodle
- Posts: 5
- Joined: Wed Feb 06, 2008 8:53 pm
Followed those instructions previously
Tried it that way
I am entering the sequence [<alt-01> etc
that way in the Find what area after having the file
opened and selecting the Replace
I am entering the sequence [<alt-01> etc
that way in the Find what area after having the file
opened and selecting the Replace
-
hexadoodle
- Posts: 5
- Joined: Wed Feb 06, 2008 8:53 pm
this is what its looking for
[<?>-><>-<ÿ>]
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Those angle brackets shouldn't be there. I explained that in my earlier message.
I don't know how the question mark got into your expression. This is what it should be:
[--ÿ]
That doesn't look right on this page, but if you copy and paste it, it should be correct. (Make sure you remove a spurious trailing space that the web page may stick on the end.)
I don't know how the question mark got into your expression. This is what it should be:
[--ÿ]
That doesn't look right on this page, but if you copy and paste it, it should be correct. (Make sure you remove a spurious trailing space that the web page may stick on the end.)
-
hexadoodle
- Posts: 5
- Joined: Wed Feb 06, 2008 8:53 pm
Oh Yes
Thank you so very much
That works like a charm
I've been working on getting that
first cntl character...
Have a great weekend
That works like a charm
I've been working on getting that
first cntl character...
Have a great weekend