RegexPatternGroup LookAhead ignored

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by tobias weltner
Avatar
If you add text at the very end of an document (so there is no text and no cr to the right of the entered text), the lookahead expression is ignored.
So if I define a token with a lookahead expression and then enter the token at the end of the document, it gets falsely identified, then after adding a space or else, it gets correctly identified.
This leads to funny color effects that are confusing to the end user.
I wished lookahead would always fail if there was no lookahead text to evaluate. Currently, it seems to be just the opposite.

Comments (1)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The problem revolves around the regex engine. It only matches patterns that result in consuming at least one character. This is how the .NET regex engine works as well.

Ideally, the LookAhead for normal keywords would be "\b" instead of "{NonWordRegex}" however since zero-width matches can't occur, we can't go that route. The use of "\b" would have allowed what you want. But if we always fail LookAhead at the end of a document when using "{NonWordRegex}", you can never have a keyword recognized at the end of a document.

So the short answer is that sorry but I think it's going to have to stay how it is.


Actipro Software Support

The latest build of this product (v24.1.0) 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.