Opened 9 years ago

Closed 7 years ago

Last modified 7 years ago

#53 closed defect (fixed)

Regular expressions 0[xX]?[0-9a-fA-F]+ and [0-9a-fA-F]+ don't find hex numbers that start with letters

Reported by: Gregg Young Owned by:
Priority: minor Milestone: Release_1.1
Component: Configuration Version: PreRelease_1.0
Keywords: Cc: Alfredo Fernández Díaz

Description (last modified by Alfredo Fernández Díaz)

Long story short: shortcoming in .TRP mode now fixed in changeset #185, as discussed through email.

Attachments (1)

0034_01.TRP (46.7 KB ) - added by Gregg Young 7 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 by Gregg Young, 9 years ago

Summary: Regular expressions 0[xX]?[0-9a-fA-F]+ and [0-9a-fA-F]+ doesn't fine hex numbers that start with lettersRegular expressions 0[xX]?[0-9a-fA-F]+ and [0-9a-fA-F]+ doesn't find hex numbers that start with letters

comment:2 by Gregg Young, 9 years ago

Summary: Regular expressions 0[xX]?[0-9a-fA-F]+ and [0-9a-fA-F]+ doesn't find hex numbers that start with lettersRegular expressions 0[xX]?[0-9a-fA-F]+ and [0-9a-fA-F]+ don't find hex numbers that start with letters

comment:3 by Gregg Young, 9 years ago

Milestone: Release_1.0Release_1.1

The problem is in the highlighting code. I can get the letters to work but the result is that then a-f get highlighted as numbers every where they appear. Probably not worth the hassle to figure out a work around. I did try {4,} in the string but it didn't seem to change anything.

comment:4 by Gregg Young, 9 years ago

Version: PreRelease_1.0

comment:5 by Alfredo Fernández Díaz, 7 years ago

I'm not sure what the problem is, I tried those expressions precisely and both work and find numbers in eFTE2 1.0 VIO and PM just fine -- AFAICT.

0[xX]?[0-9a-fA-F]+ should not find any hex number that does not start with "0"; [0-9a-fA-F]+ will match any hex number that does NOT have an X in it (or the part after the x, anyway).

I don't think [0-9a-fA-F]+ matching a-f letters 'every where they appear' is a problem: it should do so.

If you want to match hex numbers ONLY, take into account that numbers are not normally stuck-in in the middle of some text but surrounded by spaces just like words. I would try, for example, {\s|=}{0[xX]}?[0-9a-fA-F]+\s+ to match numbers between spaces (or right after an = sign) for starters. Then you can add punctuation signs, a decimal separator, other math operators, etc.

If I am mistaken or somehow misreading you, perhaps you can write a different example of unexpected behavior -- I am just trying to find what works and what does not.

Last edited 7 years ago by Alfredo Fernández Díaz (previous) (diff)

comment:6 by Alfredo Fernández Díaz, 7 years ago

OK, my previous example won't find numbers at the end of a line, because it expects to have at least one space after the figures, sorry about that. Not hard to fix, though:

{\s|=}{0[xX]}?[0-9a-fA-F]+{{\s|;}.*}?$

which will match most hex value assignments in programming code: when the number ends we may have anything (or nothing at all) before the end of line, but if there's anything, it must start with ";" or a blank character.

Of course, you need to be careful with those ".*"; f.e. in "1 + 2 = 3" the above will give three matches: each number plus the remainder of the line in each case.

comment:7 by Alfredo Fernández Díaz, 7 years ago

Cc: Alfredo Fernández Díaz added

comment:8 by Gregg Young, 7 years ago

This problem is in the highlighting code. .trp files have a bunch of hex in them and this is where I see this problem. The .trp file highlighting code is in the newest release of efte2. I am attaching a file that shows this problem. I tried your suggestions above but none of them solve the problem

by Gregg Young, 7 years ago

Attachment: 0034_01.TRP added

comment:9 by Alfredo Fernández Díaz, 7 years ago

Of course they didn't, because I had understood something different: that you were using those RegExps with Find to look for numbers, and that too many 'false' positives were being highlighted (found) when searching again.

So, you have this colorize defined for .trp files where you want all hex numbers in a certain color, and your problem is, purely alphabetical hex numbers are not highlighted (as seen eFTEing your .trp file), and what you tried to make them light up also highlights all other sequences of a-f within the text, which you don't want. I can try to brush the .trp mode up a bit if you confirm we are on the same page now.

Last edited 7 years ago by Alfredo Fernández Díaz (previous) (diff)

comment:10 by Gregg Young, 7 years ago

You are close to correct. The problem is it doesn't colorize hex numbers that start with a-f or A-F. Obviously I would like a solution that minimizes false positives (non numbers being colorized). Thanks

comment:11 by Alfredo Fernández Díaz, 7 years ago

OK, I'll try. What hex numbers do you want to highlight and how? All, all except or only those (not) in specific (sub)sections (stack dump / addresses / dwords/ chars)? One color or several?

comment:12 by Gregg Young, 7 years ago

All one color in all section. Thanks

comment:13 by Alfredo Fernández Díaz, 7 years ago

Description: modified (diff)
Resolution: fixed
Status: newclosed

comment:14 by Alfredo Fernández Díaz, 7 years ago

Component: eFTE coreConfiguration
Note: See TracTickets for help on using tickets.