Page 1 of 1

(bugs) using find regex within binaries

Posted: Thu Oct 27, 2011 4:14 pm
by chris.culler
(edited)

Didn't know where to report a bug, so I'll try here.

Searching using regex is behaving strange when case sensitivity is enabled.

Viewing a typical text file (source code) in binary file mode, I tried the following regex in the find dialog:

Code: Select all

[^[:print:]\x0d\x0a\x09]
Find-Next got hits on all occurrences of \x0d, which were specifically excluded. It did not hit on \x0a. This occurs in 5.1 and 5.4, that I know of.

After the upgrade to 5.4, I also found the following:

In binary file mode with search direction set to "down", regex [^\x0d] hits on most characters (including \x0d), but not \x64 (the letter 'd'). It seems this only happens when case sensitivity is enabled. I did not do an exhaustive test.

In binary file mode with search direction set to "up", Find-Next skips the immediately preceding character, whether it matches or not. Occurs with regex, or just a simple letter "F". Did not try other combinations or letters.

Posted: Thu Oct 27, 2011 6:17 pm
by ben_josephs
TextPad's regex recogniser doesn't recognise escape sequences within character classes. So
[^[:print:]\x0d\x0a\x09]
matches any single character that is printable and isn't one of
\ x 0 d \ x 0 a \ x 0 9
that is, one of
\ x 0 d a 9
So your regex is equivalent to
[^[:print:]\x0da9]
which is equivalent to
[^[:print:]]

Is
[^[:print:][:space:]]
close enough to what you want?
( [[:space:]] matches any one of space, tab, vertical tab, return, line feed, form feed. )