Finding lowercase (Bug?)

General questions about using TextPad

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

Post Reply
Thomas Schremser

Finding lowercase (Bug?)

Post by Thomas Schremser »

Hi everybody!

With the "Find In Files" command I wanted to find files that contain lines starting with lowercase letters and used the following regular expression for this task:

^[[:lower:]]

To my surprise the search result showed every line in every file. Only when I checked the option "Match case" it worked as desired. Since I could not find this mentioned in the documentation I wonder whether this is a bug or am I just missing something in the documentation?

Greetings from Austria
Thomas
Carlyle Sutphen

Re: Finding lowercase (Bug?)

Post by Carlyle Sutphen »

Hi, Thomas.

That seems logical to me. The [[:lower:]] construct is basically shorthand for [abcdefghijklmnopqrstuvwxyz]. If you do not specificy that case is to be matched, the search is extended to [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ].

What search routines do internally when case is to be ignored is to fold the case either up or down before comparing.
Carlyle.
Thomas Schremser

Re: Finding lowercase (Bug?)

Post by Thomas Schremser »

Hi Carlyle!

Thanks for your reply.

> That seems logical to me. The [[:lower:]] construct is basically
> shorthand for [abcdefghijklmnopqrstuvwxyz]. If you do not specificy
> that case is to be matched, the search is extended to
> [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ].

That's what doesn't seem logical to me. I wrote [[:lower:]] in my
RegExp because I wanted to search for [a-z]. If I wanted to find
[a-zA-Z] I would have written [[:alpha:]].

Anyway, at least this behaviour should be documented.

Greetings from Austria
Thomas
Carlyle Sutphen

Re: Finding lowercase (Bug?)

Post by Carlyle Sutphen »

Unfortunately, the NT command, findstr, does not recognize the shorthand class names. However, if you create a file containing two lines as follows

C:\TEMP>type x
A
a
C:\TEMP>findstr /R "[a-z]" x
a
C:\TEMP>findstr /R /I "[a-z]" x
A
a

On unix the same file with the grep command:

grep "[[:lower:]]" x
a
grep -i "[[:lower:]]" x
A
a

The search string will not change the action of the option to ignore case. If you do not check the box for matching case, you are telling TextPad to ignore case.

Now, in the TextPad help, index tab, type "regu", enter, choose "Regular Expressions" from the list of topics found, look for the section titled "Range Expressions:" about two thirds of the way down and read the last sentence in that paragraph.
Thomas Schremser

Re: Finding lowercase (Bug?)

Post by Thomas Schremser »

Hi Carlyle!

> Now, in the TextPad help, index tab, type "regu", enter, choose
> "Regular Expressions" from the list of topics found, look for the
> section titled "Range Expressions:" about two thirds of the way
> down and read the last sentence in that paragraph.

Ah, that's the problem. This special sentence is missing in the german version of the help file.

Greetings from Austria
Thomas
Post Reply