Hexdigit in dynamic lexical pattern

SyntaxEditor for WPF Forum

Posted 6 years ago by Mike
Version: 17.2.0664
Avatar

Hi,

I'm currently evaluating the syntax editor and I'm trying to highlight hexdigits. I have the following pattern:

<RegexPatternGroup TokenId="9" TokenKey="HexNumber" ClassificationTypeKey="Number" Pattern="{HexDigit}+" LookAheadPattern="{NonHexDigit}|\z" />

This works fine for hex decimals starting with a number like this:

00400ABC

but it does not work if it starts with a letter like:

ABC00400

I've also tried common regex which works fine in C# but in your script editor it doesn't. What I am doing wrong?

Comments (2)

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Mike,

Offhand, my guess is that you have another pattern group defined above this one that matches identifiers.  It could be any pattern that matches starting with alpha characters.  You would need this pattern group to be defined before that so it looks for matches first.  But I note you don't have any "0x" sort of prefix so you might run into ambiguity with knowing if your letters should be an identifier or hex number.  


Actipro Software Support

Posted 6 years ago by Mike
Avatar

You were right, the default pattern "(_ | {Alpha})({Word})*" was causing the issue. Reordering the patterns did the trick.

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.