Page 1 of 1

Expounding on a RE isn't working

Posted: Mon Sep 30, 2013 5:36 pm
by kengrubb
I have a Macro that does an RE Replace. Keeps digits (0-9) plus CR and LF. It strips everything but digits from data.

Replace: [\x00-\x09\x0B-\x0C\x0E-/:-ÿ]
With: nothing

I'd forgotten how I made this happen, but fortunately I documented it in the Macro Description.

I tried to do this RE Replace, while it's keeping 0-9 and CR and LF, it is wiping out A-Z, which I want to keep.

Replace: [\x00-\x09\x0B-\x0C\x0E-/:-@\[-ÿ]
With: nothing

To keep from going blind, let me break it out. There are a series of ranges I'm trying to replace with nothing.

\x00-\x09
\x0B-\x0C
\x0E-/
:-@
\[-ÿ

Posted: Mon Sep 30, 2013 5:48 pm
by kengrubb
I also tried this, and it didn't work.

Replace: [\x00-\x09\x0B-\x0C\x0E-\x2F\x3A-\x40\x5B-\xFF]
With: nothing

\x00-\x09
\x0B-\x0C
\x0E-\x2F
\x3A-\x40
\x5B-\xFF

Posted: Mon Sep 30, 2013 9:57 pm
by ben_josephs
You forgot about the lower-case letters.

Your character set expressions specify a set of characters that includes the lower-case letters (but not the upper-case letters).
So if Match case is selected they match lower-case letters (but not upper-case letters).
And if Match case is not selected they match both lower-case and upper-case letters.
If you want to use this technique to match neither lower- nor upper-case letters, you need to exclude both from the character set:
[\x00-\x09\x0B-\x0C\x0E-\x2F\x3A-\x40\x5B-\x60\x7B-\xFF]
which works whether Match case is selected or not.

But this is extremely obscure. It would be considerably clearer if you specifed explicitly what you don't want to match:
[^\n\r0-9A-Za-z]

Posted: Tue Oct 01, 2013 6:04 am
by kengrubb
Case. Knew it had to be something simple. Much appreciated.

Yes, the not match list is far easier to understand, but it's the not match list that I wish to keep while wiping out everything else.

Posted: Tue Oct 01, 2013 6:22 am
by ben_josephs
[^\n\r0-9A-Za-z]
means any character that's not in
[\n\r0-9A-Za-z]
It's precisely what you need (and you've used it in your sig).

Posted: Tue Oct 01, 2013 6:57 am
by kengrubb
I'm tracking now. That IS much easier.