How do I write a regular expression to find a pair of hex characters.
For example how can I find \xe8\x0D.
Thanks for your assistance. Al.
pairs of hex characters
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Re: pairs of hex characters
For hex characters in a regex, just type them as you did.
There is just one problem: \x0d is part of the End-of-Line so it will not be found.
If you want to find \xe8 at the end of a line use
\xe8$
HTH
Andreas
There is just one problem: \x0d is part of the End-of-Line so it will not be found.
If you want to find \xe8 at the end of a line use
\xe8$
HTH
Andreas
Re: pairs of hex characters
>Thanks for your prompt reply.
>I want to remove extra carriage return from a text file.
>My usual approach is to prefix each carriage return with a unique character
>such as \xe8.
>Then I replace all \xe8\n\xe8\n with \n.
>The surviving \xe8\n I replace with space.
>But I can see from your response that getting past the carriage return is a
>problem.
>
>The method does work in TextPad - using \t to prefix each \n.
>I can then replace \t\n\t\n with \n and the remaining \t\n with space.
>But I would rather use a unique character.
>Thanks again Alfred Vachris
I keep the discussion here so others may profit from it as well.
If all you want to do is just remove empty lines, search for
\n\n
and replace it by
\n
Or if there might be spaces or tabs on the "empty" lines, search for
\n[ \t]*\n
and replace it by
\n
(both cases need RegEx checked!)
Andreas
>I want to remove extra carriage return from a text file.
>My usual approach is to prefix each carriage return with a unique character
>such as \xe8.
>Then I replace all \xe8\n\xe8\n with \n.
>The surviving \xe8\n I replace with space.
>But I can see from your response that getting past the carriage return is a
>problem.
>
>The method does work in TextPad - using \t to prefix each \n.
>I can then replace \t\n\t\n with \n and the remaining \t\n with space.
>But I would rather use a unique character.
>Thanks again Alfred Vachris
I keep the discussion here so others may profit from it as well.
If all you want to do is just remove empty lines, search for
\n\n
and replace it by
\n
Or if there might be spaces or tabs on the "empty" lines, search for
\n[ \t]*\n
and replace it by
\n
(both cases need RegEx checked!)
Andreas
Re: pairs of hex characters
Andreas is right, but you will need to replace repeatedly until no more instances are found. Don't stop after one go if you want all empty lines removed. If there is one at the top, it will have to be removed manually.